我一直在尝试使用量角器和黄瓜来测试我的角度应用程序,但是当我使用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)
为什么会这样?
答案 0 :(得分:2)
[16:14:08] E/launcher - "process.on('uncaughtException'" error, see launcher
[16:14:08] E/launcher - Process exited with error code 199
上述错误可能是由于与承诺有关的各种原因造成的。但它应该抛出正确的信息。此处https://github.com/angular/protractor/issues/3384已经提供了解决确切错误消息的解决方法。
您可以更改量角器依赖关系中的launcher.ts
文件,如上述论坛中所述,以捕获错误以调试您的问题。