When I try to start my mocha test with bail(false)
I need to not stop tests even if some beforeEach
hook gives an error.
But this doesn't help, did someobody coped with this earlier? Or.. is it possible?
When I try to start my mocha test with bail(false)
I need to not stop tests even if some beforeEach
hook gives an error.
But this doesn't help, did someobody coped with this earlier? Or.. is it possible?
In order for your tests to continue running even when the beforeEach() throws an error, you have to handle that error. Currently, beforeEach() is throwing an error which is unhandled.
To handle this error in NodeJS, use a callback with a parameter:
beforeEach(done) {
// your code here
// if there was an error
if (error !== null) {
// callback with a parameter, indicates failure
done(new Error('failed'));
} else {
// more code here
// callback without parameter, indicates success!
done();
}
}