-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Asynchronous error handling #1769
Labels
type: bug
a defect, confirmed by a maintainer
Comments
this sounds like it needs fixing. |
boneskull
added
status: accepting prs
Mocha can use your help with this one!
type: bug
a defect, confirmed by a maintainer
labels
Jul 5, 2015
@boneskull , could you enable write access for me on this project so I can make push a branch and make a PR for this issue? |
@ajaykodali that's not how it works. 😄 You fork, then branch, then create a PR from your fork into mocha. |
@boneskull , ah :) cool. Will do that. Sorry about the confusion. |
@boneskull done. Here is the PR for this issue - #1802. :) |
Closed via #1802 |
boneskull
removed
the
status: accepting prs
Mocha can use your help with this one!
label
Oct 10, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This issue seems like a missing piece of this fixed issue - #1043
The issue and fix referenced in the above link is working as expected when using the hooks in sync mode. When I attempt to use the hooks in async mode (with done callback), sibling suites do not get executed.
If I have two sibling suites with async beforeEach, afterEach and tests - an async error thrown in the afterEach of the first suite will fail all tests in that suite (as expected) and also will stop execution of the second suite which does not seem expected.
Sample Code:
describe('Multiple Suites Test', function() {
// Code to throw Error in async mode
// setTimeout(function(){
// throw new Error('Error in afterEach of Suite1!!');
// },1000);
throw new Error('Error in afterEach of Suite1!!');
});
});
When the above file is executed you see the below output as expected:
Multiple Suites Test
Suite 1
Suite1:beforeEach
Suite1:Test1
✓ Suite1-Test1
Suite1:afterEach
1) "after each" hook
Suite 2
Suite2:beforeEach
Suite2:Test1
✓ Suite2-Test1
Suite2:afterEach
Suite2:beforeEach
Suite2:Test2
✓ Suite2-Test2
Suite2:afterEach
3 passing (14ms)
1 failing
Error: Error in afterEach of Suite1!!
at Context. (simpleTests.js:12:19)
If the same code is run with commented code enabled and the first afterEach in async mode, the output looks like below,
Multiple Suites Test
Suite 1
Suite1:beforeEach
Suite1:Test1
✓ Suite1-Test1
Suite1:afterEach
1) "after each" hook
1 passing (1s)
1 failing
Uncaught Error: Error in afterEach of Suite1!!
at null._onTimeout (simpleTests.js:14:23)
The second suite is completely ignored.
The text was updated successfully, but these errors were encountered: