-
Notifications
You must be signed in to change notification settings - Fork 12
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
Handle when an error occurs in a beforeEach block of a mocha test. #9
Conversation
runner.on('fail', test => failures.push(test)); | ||
runner.on('fail', (test, err) => { | ||
test.err = err; | ||
failures.push(test); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should make them all Set
instead of Array
, and then simply call tests.add(test)
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good apart of a small comment
Thanks for reporting and sorry for the late response, I was sick |
No worries about being sick! Appreciate the update! Just pushed change to using Set, let me know if that's what you had in mind otherwise I'm happy to update it to your liking. |
src/runMocha.js
Outdated
const pending = []; | ||
const failures = []; | ||
const passes = []; | ||
const tests = new Set(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mocha 3 works down to node versions that lack Set entirely; if we’re going to use it, let’s be sure to be using a polyfill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gadzooks, mocha 3 supports all the way back to node 0.10.
My personal preference would be to either:
- Revert this last commit and keep functionality w/o Set
- Bump mocha to v4.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The former is much better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I shall await @rogeliog's decision. (This was an async comment, cuz I await'ed in it. I hope my humor transcends the coldness of this comment box. :))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @ljharb
Reverted the change to Sets for node compatibility. I also included another small change that hopefully is ok to include in this PR. I noticed (when trying to use https://github.com/palmerj3/jest-junit) that the type of I did some looking and the type object that is defined in Jest also expects the property to be an Array. So I fixed that here too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks a lot! |
Hello, it's me again! Apologies for the PR's without issues!
This adds support to surface when an error occurs in a beforeEach block, before any individual tests run.
Without this change this is what is shown:
With this change we show: