Closed
Description
Version
21.6.2
Platform
windows x64
Subsystem
test_runner
What steps will reproduce the bug?
- Have a test file like
test.js
const { describe, it } = require('node:test');
const { strictEqual } = require('node:assert');
describe('math', () => {
it('addition', async () => {
await new Promise((resolve) => setTimeout(resolve, 5000));
strictEqual(1 + 1, 2);
});
it(`subtraction`, async () => {
strictEqual(1 - 1, 0);
});
});
and a reporter.js
module.exports = async function* reporter(stream) {
for await (const evt of stream) {
console.log(new Date().toISOString(), evt.type, evt.data);
}
};
- Run
node --test-reporter=./reporter.js test.js
How often does it reproduce? Is there a required condition?
100%
What is the expected behavior? Why is that the expected behavior?
test:start
should be fired before math addition
is run
What do you see instead?
test:start
is fired only after the test finishes. Here's an example log, notice that test:started is fired only after the 5 second delay, which is in fact after the tests already finished.
Additional information
I originally requested this in #46727 which resulted in test:queued and test:dequeued events being added. (Maybe this should be titled instead a general "I (still) cannot tell when a test is started")
However these are not useful because the tests are just enqueued event when they're not running: subtraction
is enqueued alongside addition
and based on the results it 'takes' 5 seconds to run, but in reality is instant.