{"action":"created","issue":{"url":"https://api.github.com/repos/Codeception/CodeceptJS/issues/358","repository_url":"https://api.github.com/repos/Codeception/CodeceptJS","labels_url":"https://api.github.com/repos/Codeception/CodeceptJS/issues/358/labels{/name}","comments_url":"https://api.github.com/repos/Codeception/CodeceptJS/issues/358/comments","events_url":"https://api.github.com/repos/Codeception/CodeceptJS/issues/358/events","html_url":"https://github.com/Codeception/CodeceptJS/issues/358","id":199320124,"number":358,"title":"Catching JS exceptions in nightmare to fail test","user":{"login":"cjhille","id":8192226,"avatar_url":"https://avatars.githubusercontent.com/u/8192226?v=3","gravatar_id":"","url":"https://api.github.com/users/cjhille","html_url":"https://github.com/cjhille","followers_url":"https://api.github.com/users/cjhille/followers","following_url":"https://api.github.com/users/cjhille/following{/other_user}","gists_url":"https://api.github.com/users/cjhille/gists{/gist_id}","starred_url":"https://api.github.com/users/cjhille/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cjhille/subscriptions","organizations_url":"https://api.github.com/users/cjhille/orgs","repos_url":"https://api.github.com/users/cjhille/repos","events_url":"https://api.github.com/users/cjhille/events{/privacy}","received_events_url":"https://api.github.com/users/cjhille/received_events","type":"User","site_admin":false},"labels":[{"id":289960751,"url":"https://api.github.com/repos/Codeception/CodeceptJS/labels/help%20wanted","name":"help wanted","color":"159818","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-01-07T00:03:03Z","updated_at":"2017-01-10T18:24:24Z","closed_at":null,"body":"I intended to extend the nightmare helper to catch JS exceptions in the browser in order to fail the current test. Since nightmare allows to listen for javascript exceptions [(doc here)](https://github.com/segmentio/nightmare#onpage-functiontypeerror-message-stack) I figured it shouldn't be to hard by doing something similar to this:\r\n\r\n```js\r\nclass NightmareHelper extends Helper {\r\n   _before() {\r\n      let browser = this.helpers['Nightmare'].browser;\r\n      browser.on('page', (type, message, stack) => { \r\n         console.log(`${message}\\n ${stack}`);\r\n         throw new Error('JS Exception in Browser!');\r\n      });\r\n   }\r\n}\r\n```\r\n\r\nThis code does return the browser stacktrace, but unfortunately it also kills the entire process instead of failing the current test. Usually throwing an error within a test just fails the current test. \r\n\r\nIs it at all possible to do this with a custom helper or could this eventually be supported by codeception itself?\r\n\r\nCodeceptJS version: 0.4.13"},"comment":{"url":"https://api.github.com/repos/Codeception/CodeceptJS/issues/comments/271655691","html_url":"https://github.com/Codeception/CodeceptJS/issues/358#issuecomment-271655691","issue_url":"https://api.github.com/repos/Codeception/CodeceptJS/issues/358","id":271655691,"user":{"login":"DavertMik","id":220264,"avatar_url":"https://avatars.githubusercontent.com/u/220264?v=3","gravatar_id":"","url":"https://api.github.com/users/DavertMik","html_url":"https://github.com/DavertMik","followers_url":"https://api.github.com/users/DavertMik/followers","following_url":"https://api.github.com/users/DavertMik/following{/other_user}","gists_url":"https://api.github.com/users/DavertMik/gists{/gist_id}","starred_url":"https://api.github.com/users/DavertMik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavertMik/subscriptions","organizations_url":"https://api.github.com/users/DavertMik/orgs","repos_url":"https://api.github.com/users/DavertMik/repos","events_url":"https://api.github.com/users/DavertMik/events{/privacy}","received_events_url":"https://api.github.com/users/DavertMik/received_events","type":"User","site_admin":false},"created_at":"2017-01-10T18:24:24Z","updated_at":"2017-01-10T18:24:24Z","body":"Sorry, checked once again. The test actually failed. Need to review it better"}}
{"actor":{"display_login":"DavertMik"}}