{"action":"created","issue":{"url":"https://api.github.com/repos/cucumber/cucumber-js/issues/617","repository_url":"https://api.github.com/repos/cucumber/cucumber-js","labels_url":"https://api.github.com/repos/cucumber/cucumber-js/issues/617/labels{/name}","comments_url":"https://api.github.com/repos/cucumber/cucumber-js/issues/617/comments","events_url":"https://api.github.com/repos/cucumber/cucumber-js/issues/617/events","html_url":"https://github.com/cucumber/cucumber-js/issues/617","id":168179326,"number":617,"title":"Use Of World.Js (Question more so)","user":{"login":"bhreinb","id":20628685,"avatar_url":"https://avatars.githubusercontent.com/u/20628685?v=3","gravatar_id":"","url":"https://api.github.com/users/bhreinb","html_url":"https://github.com/bhreinb","followers_url":"https://api.github.com/users/bhreinb/followers","following_url":"https://api.github.com/users/bhreinb/following{/other_user}","gists_url":"https://api.github.com/users/bhreinb/gists{/gist_id}","starred_url":"https://api.github.com/users/bhreinb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bhreinb/subscriptions","organizations_url":"https://api.github.com/users/bhreinb/orgs","repos_url":"https://api.github.com/users/bhreinb/repos","events_url":"https://api.github.com/users/bhreinb/events{/privacy}","received_events_url":"https://api.github.com/users/bhreinb/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-28T19:41:05Z","updated_at":"2016-07-28T20:26:36Z","closed_at":null,"body":"Hi there,\r\n\r\nPlease excuse me i'm a relative newbie to cucumber.js. I read from documentation that you put common helper properties to be used in step definitions. \r\n\r\nI also aware that the constructor is now strictly synchronous. I have questions around that. The World object (ie 'this' object) supports asynchronous calls in the steps body so how come that pattern is imposed? If you want to tag on extra functions on the this object they can't have any asynchronous calls within the method?\r\n\r\nIn addition I try to call this method from within my step definitions\r\n\r\nthis.BooleanCheckIfElementExistsAfterTimeout(YesPrefRadioButton, 10000).then(function(IsYesPrefShown)\r\n\r\nwhich is implemented in world.js as follows\r\n\r\nmodule.exports = function()\r\n{\r\n\r\n  this.World = function World()\r\n  {\r\n\r\nthis.BooleanCheckIfElementExistsAfterTimeout = function (DomElement, Timeout)\r\n\t{\r\n\t\t\r\n\t\treturn browser.wait( function() { return DomElement.isPresent().then( function(res) { return res; }); }, Timeout).then(null, function() { return false; });\r\n\t\t\r\n\t};\r\n}\r\n  \r\n}\r\n\r\nthis throws a run time error\r\n\r\nTypeError: this.BooleanCheckIfElementExistsAfterTimeout is not a function\r\n\r\nI assume that happens because there is asynchronous calls in the function body? Please correct me if I'm wrong here.\r\n\r\nIf these common helper methods that have asynchronous calls within them shouldn't reside in world.js where should be stored then? Presumably a file with module exports that we import into the step definitions?\r\n\r\nThanks in advance as to any information regarding the above."},"comment":{"url":"https://api.github.com/repos/cucumber/cucumber-js/issues/comments/236014744","html_url":"https://github.com/cucumber/cucumber-js/issues/617#issuecomment-236014744","issue_url":"https://api.github.com/repos/cucumber/cucumber-js/issues/617","id":236014744,"user":{"login":"charlierudolph","id":1676758,"avatar_url":"https://avatars.githubusercontent.com/u/1676758?v=3","gravatar_id":"","url":"https://api.github.com/users/charlierudolph","html_url":"https://github.com/charlierudolph","followers_url":"https://api.github.com/users/charlierudolph/followers","following_url":"https://api.github.com/users/charlierudolph/following{/other_user}","gists_url":"https://api.github.com/users/charlierudolph/gists{/gist_id}","starred_url":"https://api.github.com/users/charlierudolph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/charlierudolph/subscriptions","organizations_url":"https://api.github.com/users/charlierudolph/orgs","repos_url":"https://api.github.com/users/charlierudolph/repos","events_url":"https://api.github.com/users/charlierudolph/events{/privacy}","received_events_url":"https://api.github.com/users/charlierudolph/received_events","type":"User","site_admin":false},"created_at":"2016-07-28T20:26:36Z","updated_at":"2016-07-28T20:26:36Z","body":"The world constructor being synchronous does not change the ability to add asynchronous methods to it. The README has the following example\r\n```js\r\n// features/support/world.js\r\nvar zombie = require('zombie');\r\nfunction World() {\r\n  this.browser = new zombie(); // this.browser will be available in step definitions\r\n\r\n  this.visit = function (url, callback) {\r\n    this.browser.visit(url, callback);\r\n  };\r\n}\r\n\r\nmodule.exports = function() {\r\n  this.World = World;\r\n};\r\n```\r\n\r\nIn previous versions the world constructor was asynchronous and was passed a callback which needed to be called with the created world instance.\r\n\r\nYour example appears to be fine. Can you please give your full step definition file?"}}
{"actor":{"display_login":"charlierudolph"}}