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
Checked next-gen ES issues and syntax problems by using the same environment and/or transpiler configuration without Mocha to ensure it isn't just a feature that actually isn't supported in the environment in question or a bug in your code.
'Smoke tested' the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, your usage of Mocha, or Mocha itself
Ensured that there is no discrepancy between the locally and globally installed versions of Mocha. You can find them with: node node_modules/.bin/mocha --version(Local) and mocha --version(Global). We recommend avoiding the use of globally installed Mocha.
Description
When running Mocha programmatically or in a browser, mocha.run() returns the test runner instance and event handlers can be attached to it. However, when the grep option is used and it matches no tests, ]it emits the end event synchronously](https://github.com/mochajs/mocha/blob/master/lib/runner.js#L621-L623) before the runner is ever returned from mocha.run() and before any third-party code could attach a listener.
I know I can work around this by providing a callback to mocha.run(), but it still seems reasonable to expect that you’d always have an opportunity to attach an event listener before the end event fires.
Steps to Reproduce
If I have a test suite at /single-test.js that looks like:
describe('Test suite',function(){it('A single passing test',function(){// this passes});});
Prerequisites
common mistake
labelnode node_modules/.bin/mocha --version
(Local) andmocha --version
(Global). We recommend avoiding the use of globally installed Mocha.Description
When running Mocha programmatically or in a browser,
mocha.run()
returns the test runner instance and event handlers can be attached to it. However, when thegrep
option is used and it matches no tests, ]it emits theend
event synchronously](https://github.com/mochajs/mocha/blob/master/lib/runner.js#L621-L623) before the runner is ever returned frommocha.run()
and before any third-party code could attach a listener.I know I can work around this by providing a callback to
mocha.run()
, but it still seems reasonable to expect that you’d always have an opportunity to attach an event listener before theend
event fires.Steps to Reproduce
If I have a test suite at
/single-test.js
that looks like:And I run the following:
Expected behavior: I expect “End event handled!” to be logged to the console.
Actual behavior: The test suite runs, but my handler does not.
Reproduces how often: 100%
Versions
Mocha 4.0.1
The text was updated successfully, but these errors were encountered: