-
-
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: listen to 'start' and 'end' events when using Mocha programmatically #3660
Conversation
34d1d2b
to
cb1c6b0
Compare
I messed up my branch, now everything is ok. Hopefully this will reopen my PR. |
Isn't this already possible with delayed root suite? |
88da0fc
to
df86333
Compare
@plroebuck yes, but... : if there are test files found, which include the (delay) run() function. (no:
|
df86333
to
c4f23a3
Compare
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.
It seems we could instantiate the Runner
in the Mocha
constructor instead of in Mocha#run()
, and then make it a property of the Mocha
instance:
function Mocha() {
// create root suite, process options
this.runner = new Runner(rootSuite, options.delay);
}
Then users could:
const mocha = new Mocha();
mocha.runner.on('stuff', () => {})
Needs conflicts resolved
c4f23a3
to
2338a41
Compare
2338a41
to
430af80
Compare
430af80
to
c4aa79a
Compare
Outdated, I started a new approach to fix this issue
c4aa79a
to
1f31f4e
Compare
Description
mocha.run()
returns arunner
instance. Since theEVENT_RUN_BEGIN
(start
) event is emitted synchronously, it's impossible to register anEVENT_RUN_BEGIN
listener in time. The event is emitted, but never catched.When no tests are provided - eg. by a too restrictive
grep
expression - then neitherEVENT_RUN_BEGIN
norEVENT_RUN_END
(end
) events can be listened to.Description of Change
We delay the start of the root Suite by
Runner.immediately
. The order of the event emissions remains unchanged.Applicable issues
#3395 (backed out)
#3331
#3065
closes #2753