Description
Version
v24.0.0
Platform
Darwin MacBookPro 24.4.0 Darwin Kernel Version 24.4.0
Subsystem
No response
What steps will reproduce the bug?
Node 24 introduced breaking change in the test runner via #56664
Author of the PR has mentioned the following in #56664 (comment)
The only scenario where this is breaking:
test('foo', async (t) => { await t.test('subtest 1'); // It is no longer guaranteed that the subtest on the previous line has // finished by the time this line executes. But the test runner still ensures // the order that subtest 1 and subtest 2 are executed in. await t.test('subtest 2'); });
In my case a for..of
loop creates subtests dynamically and the next test must started only after previous is finished. These tests are triggering event emitter with different data and to collect output the events must appear in predictable sequence.
The example above is using await
, but it has no effect. The execution move to the second subtests without waiting for the first one to finish.
By the way, the releases notes claim that this change “makes writing tests more intuitive and reduces common errors related to unhandled promises.” Hm.. but this behaviour looks to me exactly like an unhandled promise and my intuition is rather lost: how to ensure order of execution?
Is there a chance to revert the change?
Or perhaps it makes sense adding an option that brings back the old behaviour? I use run()
in the project that got broken. So passing one more option would be fine.
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior? Why is that the expected behavior?
The test runner should only execute one test or subtest at a time within the same file. Or provide a mechanism to ensure such behaviour.
What do you see instead?
All subtest created by the for..of
loop run at the same time.
Additional information
Thank you for working on Node.js.