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
Run tests in parallel #3449
Run tests in parallel #3449
Conversation
Reduces tests execution time from 62s to 36s.
This allows to easily invoke Mocha alone via `npx mocha`, or for e.g. VSCode Test Explorer to find & run tests with the correct settings automatically.
fb25f7b
to
8079cf1
Compare
Thank you for this improvement Ingvar. There are a few util tests (cache, concurrency, counters) that require sequential running and may sporadically fail or cause other tests to fail when run in parallel. We should ensure these run after other tests have completed, perhaps via some kind of "after all" hook. |
I actually did run into that in my ahem other branch, but not with native build, even though I tried even running those asserts in a tight loop while Mocha was executing other test files. Note that Mocha's parallel mode only parallelises tests at file-level, rather than per-test level, so I guess what happens is that each individual test file gets clean environment with its own copy of native module anyway, hence the counters are indeed zero in the individual test. |
If I try to add e.g.
So it does reuse the instances, but within each instance tests are running one by one and can't step on each others' toes and concurrently modify globals - that's why counters test passes successfully. |
No worries, and yeah, it's certainly a valid concern and something I tried to test extensively before making the PR. And I'm still not 100% sure - parallel stuff is always hard 😅 Happy to make another one if something does turn out flaky. |
npx mocha
, or for e.g. VSCode Test Explorer to find & run tests with the correct settings automatically.