{"action":"created","issue":{"url":"https://api.github.com/repos/assaf/zombie/issues/840","labels_url":"https://api.github.com/repos/assaf/zombie/issues/840/labels{/name}","comments_url":"https://api.github.com/repos/assaf/zombie/issues/840/comments","events_url":"https://api.github.com/repos/assaf/zombie/issues/840/events","html_url":"https://github.com/assaf/zombie/issues/840","id":54307493,"number":840,"title":"Error while using browser.resources.fail","user":{"login":"makbol","id":5435685,"avatar_url":"https://avatars.githubusercontent.com/u/5435685?v=3","gravatar_id":"","url":"https://api.github.com/users/makbol","html_url":"https://github.com/makbol","followers_url":"https://api.github.com/users/makbol/followers","following_url":"https://api.github.com/users/makbol/following{/other_user}","gists_url":"https://api.github.com/users/makbol/gists{/gist_id}","starred_url":"https://api.github.com/users/makbol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/makbol/subscriptions","organizations_url":"https://api.github.com/users/makbol/orgs","repos_url":"https://api.github.com/users/makbol/repos","events_url":"https://api.github.com/users/makbol/events{/privacy}","received_events_url":"https://api.github.com/users/makbol/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-14T10:41:39Z","updated_at":"2015-01-15T18:27:14Z","closed_at":null,"body":"I'm trying to test my frontend script with zombie.js which sends xhr to external server. In other tests I'm using `browser.resources.mock` which works fine but i was going to test what if timeout will be reach or external server will be dead.\r\n\r\nMy code:\r\n\r\n```javascript\r\nit('should fail gracefully when external server is disabled', function(done){\r\n\r\n  browser.resources.fail('http://localhost:3000/api');\r\n  browser.resources.mock('http://localhost:3000/api', {\r\n   statusCode: 200,\r\n   headers:    { 'ContentType': 'application/json' },\r\n   body:       apiResponse1\r\n  });\r\n\r\n  browser.visit('http://localhost:3000')\r\n    .then(function() {\r\n      // sth here\r\n      done();\r\n    });\r\n});\r\n```\r\n\r\nWhat I've got is:\r\n```\r\nPossibly unhandled Error: This request was intended to fail\r\n    at failTheRequest (/Users/max/repos/abt-script/node_modules/zombie/lib/zombie/resources.js:102:19)\r\n    at Browser.Resources.specialURLHandlers (/Users/max/repos/abt-script/node_modules/zombie/lib/zombie/resources.js:378:7)\r\n    at /Users/max/repos/abt-script/node_modules/zombie/lib/zombie/resources.js:212:28\r\n    at Browser.Resources.createBody (/Users/max/repos/abt-script/node_modules/zombie/lib/zombie/resources.js:364:3)\r\n    at /Users/max/repos/abt-script/node_modules/zombie/lib/zombie/resources.js:212:28\r\n    at Browser.Resources.mergeHeaders (/Users/max/repos/abt-script/node_modules/zombie/lib/zombie/resources.js:305:3)\r\n    at /Users/max/repos/abt-script/node_modules/zombie/lib/zombie/resources.js:212:28\r\n    at Browser.Resources.normalizeURL (/Users/max/repos/abt-script/node_modules/zombie/lib/zombie/resources.js:279:3)\r\n    at /Users/max/repos/abt-script/node_modules/zombie/lib/zombie/resources.js:212:28\r\n    at Resources.runPipeline (/Users/max/repos/abt-script/node_modules/zombie/lib/zombie/resources.js:243:5)\r\n    at /Users/max/repos/abt-script/node_modules/zombie/lib/zombie/resources.js:64:22\r\n    at tryCatch2 (/Users/max/repos/abt-script/node_modules/zombie/node_modules/bluebird/js/main/util.js:29:21)\r\n    at Promise._resolveFromResolver (/Users/max/repos/abt-script/node_modules/zombie/node_modules/bluebird/js/main/promise.js:562:13)\r\n    at new Promise (/Users/max/repos/abt-script/node_modules/zombie/node_modules/bluebird/js/main/promise.js:58:37)\r\n    at Resources.request (/Users/max/repos/abt-script/node_modules/zombie/lib/zombie/resources.js:62:15)\r\n    at EventQueue.http (/Users/max/repos/abt-script/node_modules/zombie/lib/zombie/eventloop.js:256:28)\r\n    at XMLHttpRequest.send (/Users/max/repos/abt-script/node_modules/zombie/lib/zombie/xhr.js:117:30)\r\n    at Abt.sendRequest (<anonymous>:57:11)\r\n    at Abt.init (<anonymous>:21:8)\r\n    at abtScript (<anonymous>:154:7)\r\n    at <anonymous>:158:3\r\n    at Contextify.sandbox.run (/Users/max/repos/abt-script/node_modules/zombie/node_modules/jsdom/node_modules/contextify/lib/contextify.js:12:24)\r\n    at DOMWindow.window._evaluate (/Users/max/repos/abt-script/node_modules/zombie/lib/zombie/window.js:210:25)\r\n    at Object.HTML.languageProcessors.javascript (/Users/max/repos/abt-script/node_modules/zombie/lib/zombie/scripts.js:27:21)\r\n    at define.proto._eval (/Users/max/repos/abt-script/node_modules/zombie/node_modules/jsdom/lib/jsdom/level2/html.js:1675:47)\r\n    at loaded (/Users/max/repos/abt-script/node_modules/zombie/lib/zombie/scripts.js:76:23)\r\n    at /Users/max/repos/abt-script/node_modules/zombie/node_modules/jsdom/lib/jsdom/level2/html.js:89:20\r\n    at Object.item.check (/Users/max/repos/abt-script/node_modules/zombie/node_modules/jsdom/lib/jsdom/level2/html.js:361:11)\r\n    at /Users/max/repos/abt-script/node_modules/zombie/node_modules/jsdom/lib/jsdom/level2/html.js:379:12\r\n    at /Users/max/repos/abt-script/node_modules/zombie/lib/zombie/eventloop.js:263:13\r\n    at Object._onImmediate (/Users/max/repos/abt-script/node_modules/zombie/lib/zombie/eventloop.js:161:15)\r\n    at processImmediate [as _immediateCallback] (timers.js:336:15)\r\n```\r\n\r\nWhen `browser.resources.fail` is after `browser.resources.mock` then nothing happens, works fine, just like without `browser.resources.fail` "},"comment":{"url":"https://api.github.com/repos/assaf/zombie/issues/comments/70135100","html_url":"https://github.com/assaf/zombie/issues/840#issuecomment-70135100","issue_url":"https://api.github.com/repos/assaf/zombie/issues/840","id":70135100,"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-01-15T18:27:14Z","updated_at":"2015-01-15T18:27:14Z","body":"If you tell the resource to fail every request, it will fail every request, just as expected.\r\n\r\n"}}