I want to stop cucumber from running a failing test till the end because that wastes time for our continuous integration since we need rapid feedback.
I am using the javascript implementation of cucumber, cucumberJs with protractor.
Here's what I have but doesn't work:
hooks.js
this.registerHandler('AfterScenario', function (scenario, callback) {
console.log('\n After each scenario...');
if (scenario.isFailed() ===true) {
console.log('\n Scenario failed \n\n\n\n\n\n\n...');
callback.fail(new Error("\n\n\n\nThis scenario definitely failed!!"));
}
});
I included this hook.js in my protractor.conf.js like this:
cucumberOpts: {
require: [
conf.paths.e2e + '/utilities/hooks.js',
],
}
I know the hook is getting triggered from the error output below; however, can't figure out why or how to fix error:
e #01-1] Specs failed ? : C:\someFeature.feature
[chrome #01-1] Scenario failed! Creating snapshot at: C:\someFeature.png
[chrome #01-1]
[chrome #01-1]
[chrome #01-1] After each scenario...
[chrome #01-1] TypeError: e2e\utilities\hooks.js:34 scenario.isFailed is not a function
[chrome #01-1] at C:\Hooks.js:36:18
[chrome #01-1] at nextTickCallbackWith0Args (node.js:420:9)
[chrome #01-1] at process._tickCallback (node.js:349:13)