As the title implies I am trying to make my script timeout forcefully, specifically if a condition (that returns done()
) isn't met.
Here is some code:
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);
})
});
});
If I have any other mistakes in my code feel free to let me know.