当promise.then中的expect失败时,Protractor / cucumber测试套件停止运行
Protractor / cucumber test suite stop running when expect fails in promise.then
我正在研究一个使用Protractor(v 0.24.1), Cucumber(v 0.4.0), Chai(v 1.9.1)和Chai-as-promise (v 4.1.1)的测试框架。
Selinium-server-standalone.jar (v 2.41.0)chromedriver (2.10 v)在这一步中,我以两种不同的方式验证计数。一种是承诺的方式,另一种是使用chai-as-promise库来验证计数。
element.all(by.css('[ticket-id]')).then(function (tickets) {
expect(tickets.length).to.equal(2, "length correct");
//expect(tickets.length).to.equal(3, "length wrong");
});
expect(element.all(by.css('[ticket-id]')).count()).to.eventually.to.equal(2).and.notify(next);
这个通过了,我得到了消息:
1 scenario (1 passed)
3 steps (3 passed)
Process finished with exit code 0
现在,当我将then中的expect更改为fail时,所有内容都将终止。
element.all(by.css('[ticket-id]')).then(function (tickets) {
//expect(tickets.length).to.equal(2, "length correct");
expect(tickets.length).to.equal(3, "length wrong");
});
现在我只得到消息:
Process finished with exit code 1
此错误停止测试执行,没有堆栈跟踪或任何帮助调试的东西。有人知道这是为什么吗?
我们正在考虑更新量角器,这可能会有所帮助。
下面的解决方案解决了您的问题:
element.all(by.css('[ticket-id]')).then(function (tickets) {
expect(tickets.length).to.equal(2, "length correct");
//expect(tickets.length).to.equal(3, "length wrong");
}).catch(function(err){
callback(err);
});
expect(element.all(by.css('[ticketid]')).count()).to.eventually.to.equal(2).and.notify(next);
相关文章:
- 模糊事件的Javascript测试
- 我的单元测试选项是什么
- 测试索引值是否等于某个数字的倍数
- 在localhost Dev Box上测试JSONP请求的最佳方式
- 测试数组中每个项的内容
- 测试Angular Service解决错误回调中的promise
- 使用Jest测试React Native应用程序
- 为函数代码编写测试
- 如何在Angular单元测试中从另一个控制器的rootScope将方法添加到rootScope中
- 如何使用JS/nightwatchjs并行运行多个测试
- 使用量角器的当前url单元测试的getTitle
- 茉莉花宝石-耙茉莉花:ci dons't运行测试
- JavaScript滚动脚本-在测试中激发,而不是在开发站点上
- AngularJS指令单元测试中未定义的函数
- 一个密码测试程序,如果存在空格,它会提醒用户
- 当promise.then中的expect失败时,Protractor / cucumber测试套件停止运行
- 在free + cucumber中进行无头JavaScript测试
- 在Cucumber中测试JQuery UI滑块
- 在cucumber中测试javascript的内容
- 在使用Cucumber进行测试时,Stripe JS会失败