我一直在尝试使用量角器和黄瓜测试我的角度应用程序,但是当我使用 mocha 来创建期望时,当期望为假时,错误规范不会显示在控制台中。
路由http://localhost:9000/#/form29/form29的相关 HTML '
...
<h4 class="title">
The title
</h4>
...
我的步骤文件是:
//form29_steps.js
var chai = require('chai'),
chaiAsPromised = require('chai-as-promised'),
assert;
chai.use(chaiAsPromised);
expect = chai.expect;
module.exports = function () {
this.Given(/^I am in the form 29 page$/, function (done) {
browser.get('http://localhost:9000/#/form29/form29');
done();
});
this.Then(/^should be the title "(.*)"/,function(title, done){
var el = element(by.css('.title'));
el.getText().then(function(text){
//a false expect
expect(title).to.eq('Aaaaa');
done();
});
});
};
当期望它有效时它可以,但是当期望失败时没有期望失败错误并显示以下内容:
[16:14:08] E/launcher - "process.on('uncaughtException'" error, see launcher
[16:14:08] E/launcher - Process exited with error code 199
当我尝试相同但不使用承诺时,效果很好
this.Then(/^should be the title "(.*)"/,function(title, done){
var el = element(by.css('.title'));
expect(title).to.eq('A');
done();
});
我得到了我希望的错误:
Message:
AssertionError: expected 'Formulario 29' to equal 'A'
at World.<anonymous> (/protractor/test/e2e/features/step_definitions/form29_steps.js:18:20)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
为什么会这样?