这是最小的例子:
UITextView
这是输出:
module.exports = {
before: function(browser, done) {
},
'Actual Test': function() {
},
};
但退出代码是0,而不是1
Starting selenium server... started - PID: 91910
[Timeout] Test Suite
========================
_________________________________________________
TEST FAILURE: 1 error during execution, 0 assertions failed, 0 passed. (10.09s)
✖ timeout
done() callback timeout of 10000 ms was reached while executing "before". Make sure to call the done() callback when the operation finishes.
SKIPPED:
- Actual Test
我希望退出代码为1,这样我就可以检测到测试失败。有没有办法让退出代码非零?
答案 0 :(得分:0)
Nightwatch预计会在done()
方法中进行before()
回调:
module.exports = {
before: function(browser, done) {
...some initialization...
done(); // <--- here
}
};
从技术上讲,你的测试是通过的(0测试失败0),它只是一个不正确的流程管理,可能Nightwatch应该将错误等问题视为返回1。 我相信在大多数情况下你想要捕获一些实际的测试失败,在这种情况下你应该添加一些真正的断言,如果它失败了那么你将获得退出代码1:
module.exports = {
before: function(browser, done) {
done();
},
'Actual Test': function(browser) {
browser.url('http://somewhere.com');
browser.assert.urlEquals('http://www.google.com'); // <-- test fails with return status code 1
}
};