-
Notifications
You must be signed in to change notification settings - Fork 286
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
any showcase for node:test concurrency
options?
#3837
Comments
Hi. test('multi level test', { concurrency: 2 }, async (t) => {
await Promise.all([
t.test('subtest 1', async () => {
console.log('1');
await setTimeout(2000);
console.log('11');
});
t.test('subtest 2', async () => {
console.log('2');
await setTimeout(1000);
console.log('22');
});
]);
}); or with descrie('multi level test', { concurrency: 2 }, async () => {
it('subtest 1', async () => {
console.log('1');
await setTimeout(2000);
console.log('11');
});
it('subtest 2', async () => {
console.log('2');
await setTimeout(1000);
console.log('22');
});
}); |
I cannot get it work, with the following code: const test = require('node:test')
const assert = require('node:assert/strict')
const wait = (ms) => new Promise((resolve) => setTimeout(() => resolve(), ms))
const input = [{
expected: 2,
actual: 2
}, {
expected: 'ola',
actual: 'ciao'
}]
input.forEach((el, index) => {
test('should work', { concurrency: true }, async (t) => {
console.log(`start-${index}`)
await wait(3000)
assert.strictEqual(el.actual, el.expected)
console.log(`end-${index}`)
})
}) node version: I'm running it with const { junit } = require('node:test/reporters')
const { run } = require('node:test')
const path = require('node:path')
run({ concurrency: true, files: [path.resolve(__dirname, './test-suite-1.js')] })
.compose(junit)
.pipe(process.stdout) |
with the first showcase, |
It seems there has been no activity on this issue for a while, and it is being closed in 30 days. If you believe this issue should remain open, please leave a comment. |
It seems there has been no activity on this issue for a while, and it is being closed. If you believe this issue should remain open, please leave a comment. |
Details
as https://nodejs.org/dist/latest-v18.x/docs/api/test.html#testname-options-fn docs says, subtests could run concurrency.
when try as:
itdon't work, since each subtests is
awaited
.but if write test like below:
got error:
Node.js version
18.0.0
Example code
No response
Operating system
macOS
Scope
test
Module and version
Not applicable.
The text was updated successfully, but these errors were encountered: