Mocha.js checks the deposit (false), does not work for beforeEach

When I try to start my mocha test using bail(false) , I need not to stop the tests, even if some hook beforeEach gives an error.

But it doesnโ€™t help, but has someone dealt with this before? Or is it possible?

+4
source share
1 answer

To keep your tests running even when the beforeEach () function throws an error, you need to handle this error. Currently, beforeEach () throws an error that is not being processed.

To handle this error in NodeJS, use the callback with the 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(); } } 
0
source

Source: https://habr.com/ru/post/1484202/


All Articles