-
-
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
Using async/await within context blocks don't work as expected #3593
Comments
Just to add to the discussion that our company got caught out by the non-async nature of describe when a developer changed from describe.only('aqs.utils', async () => {
await import('./equals');
await import('./gas');
await import('./notEquals');
await import('./startsWith');
await import('./wordSearch');
}); We went back to the original and now works as expected, but I think we would prefer to use describe.only('aqs.utils', () => {
require('./equals');
require('./gas');
require('./notEquals');
require('./startsWith');
require('./wordSearch');
}); |
@boneskull have this issues been completely abandoned or there are plans to address them? I have recently encountered the same problem as @WORMSS. Using dynamic ES6 modules are a standard for us. Mixing ES6 modules syntax with CJS My tests are being ultimately run, even if placed inside an "async" EDIT: Throwing a warning when a promise is returned to a |
I would entertain a PR to allow for async suites, but it's not on the top of my todo list. I think it's something that should get done, anyway, and would appreciate assistance |
Prerequisites
faq
labelnode node_modules/.bin/mocha --version
(Local) andmocha --version
(Global). We recommend avoiding the use of globally installed Mocha.Description
When using async/await inside of a context block, the code order execution does not line up with my expectations. Based on a similar issue: #2975, is it possible to run the following code without the use of a before block? If it's not possible it would require me to wrap my
for loop
within mySibling Context 1
in ait block
for the code to function in the order I expect.As a workaround, I've implemented the structure like so:
Note I understand that use of arrow functions is discouraged (https://mochajs.org/#arrow-functions) but my current team seems to prefer them over using
function()
The following example in Steps to Reproduce appears to be a possible bug.
Steps to Reproduce
mocha test_file.js
output: (Notice that Sibling Context 1 was not provided as an output when running the code)
mocha testfile.js
output:
0 passing
Expected behavior:
Actual behavior:
When the following block of code is commented out as described in step 3, the following output is displayed. No Tests are ran
Reproduces how often: 100% of the time
Versions
mocha --version
andnode node_modules/.bin/mocha --version
: 5.2.0node --version
: v10.11.0Additional Information
The text was updated successfully, but these errors were encountered: