我想阻止 cucumber 一直运行失败的测试,因为这会浪费我们持续集成的时间,因为我们需要快速反馈。
我正在使用带有量角器的黄瓜 cucumberJs 的 javascript 实现。
这是我拥有但不起作用的内容:
钩子.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!!"));
}
});
我将这个hook.js包含在我的protractor.conf.js中,如下所示:
cucumberOpts: {
require: [
conf.paths.e2e + '/utilities/hooks.js',
],
}
我知道钩子是从下面的错误输出中触发的;但是,无法弄清楚为什么或如何修复错误:
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)