You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
describe('first',function(){before(function(done){process.nextTick(function(){thrownewError('failed')});})it('should do something',function(done){done()})})describe('second',function(){it('should something',function(done){done()})})
As you can see, I have a first test suite with a before hook throwing an exception. I'm expecting this first test suite to failed.
Then, I have an other test suite, outside the first one. This one should passed.
Now, here what happen:
first
1) "before all" hook
0 passing (3ms)
1 failing
1) first "before all" hook:
Uncaught Error: failed
at /home/tetienne/test.js:4:13
at process._tickCallback (node.js:419:13)
The second test suite is not run at all.
In the sync world, it works as expected:
describe('first',function(){before(function(){thrownewError('failed');})it('should do something',function(){})})describe('second',function(){it('should something',function(){})})
first
1) "before all" hook
second
✓ should something
1 passing (4ms)
1 failing
1) first "before all" hook:
Error: failed
at Context.<anonymous> (/home/tetienne/test2.js:3:13)
at callFn (/home/tetienne/.node_modules/lib/node_modules/mocha/lib/runnable.js:250:21)
at Hook.Runnable.run (/home/tetienne/.node_modules/lib/node_modules/mocha/lib/runnable.js:243:7)
at next (/home/tetienne/.node_modules/lib/node_modules/mocha/lib/runner.js:258:10)
at Object._onImmediate (/home/tetienne/.node_modules/lib/node_modules/mocha/lib/runner.js:275:5)
at processImmediate [as _immediateCallback] (timers.js:345:15)
So to sum up, as soon as an async before hook catch an error, all the next tests, even unrelated, failed.
Have you any idea on what is wrong here?
The text was updated successfully, but these errors were encountered:
You throw an error that is unhandled. Read the error message. "Uncaught Error" means that something fucked up and there was no one to clean up. The program has no choice but to exit.
In the async world, you need to manage errors by using the callback parameter when creating async test. This just means before(function (done) { done(new Error('failed')); }).
Hi all,
This issue is simular to #581 but in the async world. I'm using [email protected].
Here a simple test to reproduce my issue:
As you can see, I have a first test suite with a before hook throwing an exception. I'm expecting this first test suite to failed.
Then, I have an other test suite, outside the first one. This one should passed.
Now, here what happen:
The second test suite is not run at all.
In the sync world, it works as expected:
So to sum up, as soon as an async before hook catch an error, all the next tests, even unrelated, failed.
Have you any idea on what is wrong here?
The text was updated successfully, but these errors were encountered: