【发布时间】:2016-03-26 07:53:26
【问题描述】:
我正在用 nightwatch.js 做 JavaScript e2e 测试,我想用 sinon.js 的假计时器来模拟时钟 http://sinonjs.org/docs/#clock
但是测试在完成之前就停止了,我得到了如下的日志,并且不再进行了。
[some test] Test Suite
===============================
✔ Element <body> was visible after 5000 milliseconds.
我的测试代码如下。我该如何解决这个问题?谢谢。
module.exports = {
before: function(browser) {
clock = sinon.useFakeTimers(new Date(2015, 7, 20).getTime());
},
after: function(browser) {
clock.restore();
browser.end();
},
'some test': function(browser) {
const browserName = this.client.options.desiredCapabilities.browserName;
browser
.url('some/path/')
.waitForElementVisible('body', 5000)
.pause(5000); // I need to use pause here
clock.tick(5001);
browser
.expect.element('.someElement').to.be.enabled;
},
};
【问题讨论】:
标签: javascript sinon nightwatch.js e2e-testing