I'm running this test (simplified), which fails as expected ... but despite the failure, it still waits for the full 20 second timeout. How can I make it fail immediately?
it("should fail before timeout", function (done) {
var nightmare = new Nightmare({ show: true })
.goto(url)
.evaluate(function () {
})
.then(function (result) {
// this point is reached, and then the test just waits
// 20 seconds before finally failing
throw "Fail"
})
})
This is an error using mocha
. Instead of throwing, then
should call done with an Error
object. (also replaced throw "Fail"
with throw new Error("Fail")
)