【发布时间】:2018-10-06 14:31:38
【问题描述】:
正如标题所暗示的,我正在尝试强制让我的脚本超时,特别是在不满足条件(返回 done())的情况下。
这里有一些代码:
import * as Nightmare from "nightmare";
describe("Login Page", function() {
this.timeout("30s");
let nightmare = null;
beforeEach(() => {
nightmare = new Nightmare({ show: true });
});
let pageUrl;
describe("give correct details", () => {
it("should log-in, check for current page url", done => {
nightmare
.goto(www.example.com/log-in)
.wait(5000)
.type(".input[type='email']", "username")
.type(".input[type='password']", "password")
.click(".submit")
.wait(3000)
.url()
.exists(".navbar")
.then(function(result) {
if (result) {
done();
} else {
console.log("failure");
// I want it to timeout here
}
})
.catch(done);
})
.end()
.then(url => {
pageUrl = url;
console.log(pageUrl);
})
});
});
如果我的代码中有任何其他错误,请随时告诉我。
【问题讨论】:
-
您需要向我们展示一些实际的噩梦代码,然后添加一些关于您想要超时的代码中的确切内容的解释,以便我们能够帮助您解决任何级别的问题细节。
-
@jfriend00 完成。
标签: javascript node.js typescript mocha.js nightmare