Description
Version
v19.8.1
Platform
Darwin Bumbles-MBP.home 21.6.0 Darwin Kernel Version 21.6.0: Mon Dec 19 20:44:01 PST 2022; root:xnu-8020.240.18~2/RELEASE_X86_64 x86_64
What steps will reproduce the bug?
Use this repo https://github.com/iambumblehead/demo-slow-node-test
from the package,
npm run test-ava
takes about 10 seconds
npm run test-node-describe
takes about 30 seconds
npm run test-node-test
takes about 30 seconds
How often does it reproduce? Is there a required condition?
It is reproduced any time the test repo is used on this machine
What is the expected behavior? Why is that the expected behavior?
node:test should use multiple cores and should not be slow
What do you see instead?
Hello, I recently replaced node:test with ava in a project using ~250 tests. The node:test runner would complete in ~18 minutes and the ava runner completes in ~9 minutes. The node:test version of the project used describe/it tests with the following pattern,
describe('app', { concurrency: true }, async () => {
beforeEach(() => {
nock.disableNetConnect();
});
it('test a', async () => {
assert.ok(true);
});
it('test b', async () => {
assert.ok(true);
});
// ...
});
Additional information
Test concurrency might have some problems. Initially, I tried using { concurrency: true }
with a single file that contained about a dozen tests and tests completed in a time that was observably faster. When { concurrency: true }
was used with multiple files, the improvement seemed to go away and each group of tests would run slowly,
Test concurrency requires extra boilerplate. Eg, to run tests concurrently, one needs to use nested describe/it tests, nested tests wrapped in a promise or use a configuration file. related links here, and here. It would be nice if concurrent tests were easier to achieve with a special import import test from 'node:test/concurrent'
or with a cli option --test-concurrency=true
, link to a related comment here: do not expose a test-concurrency flag.
Thank you