You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importassertfrom"node:assert/strict";importtestfrom"node:test";import{setTimeout}from"node:timers/promises";awaittest("test suite",async(t)=>{t.before(async()=>{console.log("before start");awaitsetTimeout(100);console.log("before end");});t.beforeEach(async()=>{console.log("beforeEach start");awaitsetTimeout(100);console.log("beforeEach end");});t.afterEach(async()=>{console.log("afterEach start");awaitsetTimeout(100);console.log("afterEach end");});t.after(async()=>{console.log("after start");awaitsetTimeout(100);console.log("after end");});awaitt.test("test case",async()=>{console.log("test case start");awaitsetTimeout(100);assert.ok(true);console.log("test case end");});});
the expected output is
before start
before end
beforeEach start
beforeEach end
test case start
test case end
afterEach start
afterEach end
after start
after end
instead of
before start
beforeEach start << "beforEach" strarts before "before end"
before end
beforeEach end
test case start
test case end
afterEach start
afterEach end
after start
after end
If the hooks are not async then the order is correct.
In earlier node version the await keyword helped before the hooks but in node 22.0.0 it doesn't work.
How often does it reproduce? Is there a required condition?
always
What is the expected behavior? Why is that the expected behavior?
the expected console log is
before start
before end
beforeEach start
beforeEach end
test case start
test case end
afterEach start
afterEach end
after start
after end
What do you see instead?
before start
beforeEach start << "beforEach" strarts before "before end"
before end
beforeEach end
test case start
test case end
afterEach start
afterEach end
after start
after end
Version
v22.0.0
Platform
Darwin Kernel Version 23.4.0
Subsystem
test_runner
What steps will reproduce the bug?
run the following code with node 22.0.0.
the expected output is
instead of
If the hooks are not async then the order is correct.
In earlier node version the
await
keyword helped before the hooks but in node 22.0.0 it doesn't work.How often does it reproduce? Is there a required condition?
always
What is the expected behavior? Why is that the expected behavior?
the expected console log is
What do you see instead?
Additional information
if you need git repo https://github.com/ert78gb/node-22-test-runner-async-hooks
The text was updated successfully, but these errors were encountered: