-
-
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
fix to bail option works properly with hooks #3278
Conversation
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.
Awesome, thanks. I only have one nitpick. If you agree, please fix & go ahead and merge this.
'use strict'; | ||
|
||
describe('suite1', function () { | ||
it('should only display this error', function (done) { |
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.
please remove the done
parameter in this function and below; they aren't necessary for what these tests are proving.
I removed |
IMO, this should be backed out. Believe it's completely wrong. |
Why? |
bail should call those events you mentioned. if it’s not, I agree it’s wrong. past that, whether more hooks should run is a matter of opinion. some would prefer an immediate process exit with exception, others would like cleanup. but fwiw I’m feeling wishy-washy on it |
I think:
If we manage to do the setup, we should be responsible for the teardown. |
Was this fix to #3096 overkill, then? @outsideris? |
IMO, it definitely doesn't seem to be |
When I try to fix bail issues, I just treated them like a bug. Now, I realized many people have different expectationsΩ for bail option. However, I still didn't understand why people want to clean up them when they run mocha with bail. I think current bail's behavior is fit for the definition.
If we run |
If you launch a background server (in setup), it will be using a port. If you terminate without shutting the server down, that port will still be in use. Now you can't trivially restart your test without going back to shell to determine the server pid to kill it manually. Would make
That would be the best case scenario, but I'm realistic about it. The point was to try to recover. |
Why the case which you provide is handled by |
I don't use |
Users of two cases, only |
Description of the Change
With bail option, all tests must be stopped after first test failure. However, bail option doesn't stop hooks such as
after
orafterEach
.Alternate Designs
I have no idea.
Why should this be in core?
It's a bug. It makes bail works correctly.
Benefits
A user can use bail intentionally.
Possible Drawbacks
No.
Applicable issues
Fix #3096 .
It is patch release.