{"action":"created","issue":{"url":"https://api.github.com/repos/assaf/zombie/issues/903","labels_url":"https://api.github.com/repos/assaf/zombie/issues/903/labels{/name}","comments_url":"https://api.github.com/repos/assaf/zombie/issues/903/comments","events_url":"https://api.github.com/repos/assaf/zombie/issues/903/events","html_url":"https://github.com/assaf/zombie/issues/903","id":70405880,"number":903,"title":"Can we do the assertion in the callback of `browser.visit` as the document shows?","user":{"login":"freewind","id":333781,"avatar_url":"https://avatars.githubusercontent.com/u/333781?v=3","gravatar_id":"","url":"https://api.github.com/users/freewind","html_url":"https://github.com/freewind","followers_url":"https://api.github.com/users/freewind/followers","following_url":"https://api.github.com/users/freewind/following{/other_user}","gists_url":"https://api.github.com/users/freewind/gists{/gist_id}","starred_url":"https://api.github.com/users/freewind/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freewind/subscriptions","organizations_url":"https://api.github.com/users/freewind/orgs","repos_url":"https://api.github.com/users/freewind/repos","events_url":"https://api.github.com/users/freewind/events{/privacy}","received_events_url":"https://api.github.com/users/freewind/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-23T13:00:49Z","updated_at":"2015-04-23T15:17:24Z","closed_at":null,"body":"In the document of http://zombie.js.org/, there is an example:\r\n\r\n```js\r\nbrowser.visit('/path', function() {\r\n  assert(browser.location.href == 'http://example.com/path');\r\n});\r\n```\r\n\r\nIt does the assertion in the callback of `browser.visit`, is it the correct way?\r\n\r\nWhen I use `mocha` to run such a test, I found it always success, even if the assertion is failed.\r\n\r\nI searched the keyword `browser.visit` in the codebase of zombie, didn't find similar usage, instead, it does the assertion out of the `visit`, like:\r\n\r\n```js\r\nbefore(function(done) {\r\n    browser.visit('/path', function() { done(); });\r\n});\r\n\r\nit(\"should do something\", function() {\r\n   assert(browser.location.href == 'http://example.com/path');\r\n});\r\n```\r\n\r\nI'm not sure which is the correct way."},"comment":{"url":"https://api.github.com/repos/assaf/zombie/issues/comments/95621976","html_url":"https://github.com/assaf/zombie/issues/903#issuecomment-95621976","issue_url":"https://api.github.com/repos/assaf/zombie/issues/903","id":95621976,"user":{"login":"assaf","id":5158,"avatar_url":"https://avatars.githubusercontent.com/u/5158?v=3","gravatar_id":"","url":"https://api.github.com/users/assaf","html_url":"https://github.com/assaf","followers_url":"https://api.github.com/users/assaf/followers","following_url":"https://api.github.com/users/assaf/following{/other_user}","gists_url":"https://api.github.com/users/assaf/gists{/gist_id}","starred_url":"https://api.github.com/users/assaf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/assaf/subscriptions","organizations_url":"https://api.github.com/users/assaf/orgs","repos_url":"https://api.github.com/users/assaf/repos","events_url":"https://api.github.com/users/assaf/events{/privacy}","received_events_url":"https://api.github.com/users/assaf/received_events","type":"User","site_admin":false},"created_at":"2015-04-23T15:17:23Z","updated_at":"2015-04-23T15:17:23Z","body":"Check the example at the very top of the documentation. Semantically, this is the better way to write tests: the test body makes assertion about the document, loading that document happens in the setup (`before` in Mocha).\r\n\r\nThe second example you cited is just to illustrate how `Browser.localhost` works. However, in practice it should work just like the first example. If it doesn't, I would appreciate a pull request with a test case to show where it fails. "}}