【发布时间】:2017-11-22 04:08:10
【问题描述】:
我使用基于 Nightwatch.js 的 Nightwatch-Cucumber 在 node.js 中实现了一个新的自动化测试测试框架。所以,有时我使用 node.js 断言来检查一些值。我在我的框架中使用 PageObject 模式。我的问题是断言失败后浏览器会话没有关闭,我不知道为什么,也不知道如何解决问题。
这是我的 StepDefinition:
const {
client
} = require('nightwatch-cucumber');
const {
defineSupportCode
} = require('cucumber');
const page = client.page.page();
defineSupportCode(({Given, When, Then}) => {
When(/^test$/, () => {
return page.test();
});
});
这就是我的 PageObject 函数:
module.exports = {
elements: {},
commands: [{
test() {
//here the assertion failed and the browser session still exist and doen't close
this.assert.equal(false, true);
return this.api;
}
}]
};
那么,我该怎么做才能实现关闭浏览器和会话以进行测试?只有在 node.js 断言失败时才会发生这种情况。
【问题讨论】:
标签: javascript node.js assert nightwatch.js assertions