-
-
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
--grep and .only result in 0 tests running when using async describe with await #3168
Comments
Related to this is that you must use an
This results in:
When you would expect 2 tests to run. If you then change this to a more direct approach:
It results in:
Expected behavior would be 2 tests running. Note that this seems to be due to some kind of race condition. If you add a synchronous
output:
|
I've resolved this with the --delay flag Would be good to add this as a hint to the docs in the section on asynchronously adding tests
|
Prerequisites
common mistake
labelnode node_modules/.bin/mocha --version
(Local) andmocha --version
(Global). We recommend avoiding the use of globally installed Mocha.Description
When you have a describe function that is async, and use an await statement within that function, tests run fine, except when using
--grep
oronly
.Steps to Reproduce
Create this simple test suite to reproduce the issue:
This works:
node_modules/mocha/bin/mocha
(2 passing)This does NOT work:
node_modules/mocha/bin/mocha --grep="one"
(0 passing)Adding
.only
also does NOT work.Expected behavior: [What you expect to happen]
Expect it to run the function matching grep or
.only
Actual behavior: [What actually happens]
0 tests are passing/failing/pending
Reproduces how often: [What percentage of the time does it reproduce?]
100%
Versions
Mocha 4.0.1
Node 9.2.1
OSX Sierra
Additional Information
I need to use
await
inside describe because the inner tests use a port that is found using an async library to discover unused ports.The text was updated successfully, but these errors were encountered: