{"action":"created","issue":{"url":"https://api.github.com/repos/cucumber/cucumber-js/issues/319","labels_url":"https://api.github.com/repos/cucumber/cucumber-js/issues/319/labels{/name}","comments_url":"https://api.github.com/repos/cucumber/cucumber-js/issues/319/comments","events_url":"https://api.github.com/repos/cucumber/cucumber-js/issues/319/events","html_url":"https://github.com/cucumber/cucumber-js/issues/319","id":66736014,"number":319,"title":"How Hooks are Wired Up and Naming of Files","user":{"login":"dschinkel","id":338798,"avatar_url":"https://avatars.githubusercontent.com/u/338798?v=3","gravatar_id":"","url":"https://api.github.com/users/dschinkel","html_url":"https://github.com/dschinkel","followers_url":"https://api.github.com/users/dschinkel/followers","following_url":"https://api.github.com/users/dschinkel/following{/other_user}","gists_url":"https://api.github.com/users/dschinkel/gists{/gist_id}","starred_url":"https://api.github.com/users/dschinkel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dschinkel/subscriptions","organizations_url":"https://api.github.com/users/dschinkel/orgs","repos_url":"https://api.github.com/users/dschinkel/repos","events_url":"https://api.github.com/users/dschinkel/events{/privacy}","received_events_url":"https://api.github.com/users/dschinkel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-04-07T00:04:42Z","updated_at":"2015-04-30T17:36:09Z","closed_at":null,"body":"I am looking at the docs but still something is not clear to me.  \r\n\r\nI get how to create hooks and all that but how are the hooks connected to World.  Meaning how does Cucumber look for your hooks file and .Before for example in your hooks.js and do you have to name it hooks.js or does it not matter as long as you have a .Before for a before hook for example?\r\n\r\nIs it that because you do a module.exports of your hooks function that somehow Cucumber magically pics up your hooks function and calls it?\r\n\r\nRight now it's not calling my hook (console.log(\"inside Before\"); is not logging to the console).  \r\n\r\nI'm running Cucumber 0.4.8\r\n\r\nsupport/hooks.js\r\n-----------------------\r\n\r\n\"use strict\";\r\n\r\nvar phantom = require('phantom');\r\n\r\nvar beforeHooks = function () {\r\n    this.Before(function(callback) {\r\n\r\n        console.log(\"inside Before\");\r\n\r\n        phantom.create(\"--web-security=no\", \"--ignore-ssl-errors=yes\", { port: 12345 }, function (ph) {\r\n            var phantomProcess = ph;\r\n\r\n            this.createBrowserPage = function(){\r\n\r\n                phantomProcess.createPage(function(page) {\r\n                    console.log(\"creating page\");\r\n                    this.headlessPage = page;\r\n                });\r\n            };\r\n        });\r\n        callback();\r\n    });\r\n};\r\n\r\nmodule.exports = beforeHooks;\r\n\r\n\r\n/support/world.js\r\n--------------------\r\n\r\n\"use strict\";\r\n\r\nvar hooks = require('./hooks.js');  // I've seen people set it here and set it to a variable but I have nothing to really call in my hooks so do I need this?\r\n\r\nvar World = function World(callback) {\r\n    console.log(\"inside world\");\r\n    callback();\r\n};\r\n\r\nmodule.exports.World = World;\r\n\r\n\r\nsupport/myStepDefinitions.js\r\n-----------------------------\r\n\"use strict\";\r\n\r\nvar viewingEpisodesList = function() {\r\n\r\n    this.World = require(\"../../support/world.js\").World;\r\n    this.createBrowserPage;\r\n    console.log(\"this.headlessPage: \" + this.headlessPage);\r\n    var page = this.headlessPage;\r\n\r\n    this.Given(/^I visit the customers display page$/, function (callback) {\r\n\r\n        console.log(\"page: \" + page);\r\n        page.open(\"/\", function(status){\r\n\r\n            status.should.equal(\"success\");\r\n            callback();\r\n        });\r\n    });\r\n};\r\n\r\nmodule.exports = viewingEpisodesList;"},"comment":{"url":"https://api.github.com/repos/cucumber/cucumber-js/issues/comments/97891887","html_url":"https://github.com/cucumber/cucumber-js/issues/319#issuecomment-97891887","issue_url":"https://api.github.com/repos/cucumber/cucumber-js/issues/319","id":97891887,"user":{"login":"thompsnm","id":5762421,"avatar_url":"https://avatars.githubusercontent.com/u/5762421?v=3","gravatar_id":"","url":"https://api.github.com/users/thompsnm","html_url":"https://github.com/thompsnm","followers_url":"https://api.github.com/users/thompsnm/followers","following_url":"https://api.github.com/users/thompsnm/following{/other_user}","gists_url":"https://api.github.com/users/thompsnm/gists{/gist_id}","starred_url":"https://api.github.com/users/thompsnm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thompsnm/subscriptions","organizations_url":"https://api.github.com/users/thompsnm/orgs","repos_url":"https://api.github.com/users/thompsnm/repos","events_url":"https://api.github.com/users/thompsnm/events{/privacy}","received_events_url":"https://api.github.com/users/thompsnm/received_events","type":"User","site_admin":false},"created_at":"2015-04-30T17:36:09Z","updated_at":"2015-04-30T17:36:09Z","body":"@jrust , check your Protractor Config file. From your description, I'm betting your `cucumberOpts.require` array includes all contents of your step_definitions folder, but does not include the folder you previously had your hooks in. If your hooks file wasn't required before then your hooks wouldn't run. @dschinkel , your description sounds like a similar problem, but I don't know what the analogous solution would be if you're just using cucumberjs (I'm using it with Protractor myself). I'd say make sure to require your support folder wherever you're currently requiring your step_definitions folder."}}