I am running into a simple issue, I have about 5 tests to be part of one group, one of them I am forcing them to fail but I am not able to exit the fail state:
.goto(url)
.wait('#element')
.evaluate(fnc...)
wait('#newelement')
....
evaluate(function(){
return document.querySlector('#myid').innerText
})
.then(function(result) {
result.should.equal('1');// I know I am expecting 2
done();
})
// will never be executed.
.then.....
// The following message is thrown. Error: timeout of 15000ms exceeded. Ensure the done() callback is being called in this test.
It would be OK, however there are other tests that I need to make after this one fails but I can't seem to be able to continue or have an elegant way to report the failure without affecting the rest.
If you want to force a test to fail you can call done
passing an error as an argument:
done(new Error('this is my error message'))
So in your case, something like this:
.goto(url)
.wait('#element')
.evaluate(fnc...)
wait('#newelement')
....
evaluate(function(){
return document.querySlector('#myid').innerText
})
.then(function(result) {
done(new Error('Please test, fail because I want you to.'));
})
// will never be executed.
.then.....
Also, as a side note, your original code might not work, because of multiple calls to evaluate
on the same chain call, see this answer for more details.