diff --git a/lib/internal/test_runner/harness.js b/lib/internal/test_runner/harness.js index 202759bdbfe7ae..5f43e846f29585 100644 --- a/lib/internal/test_runner/harness.js +++ b/lib/internal/test_runner/harness.js @@ -225,7 +225,11 @@ function getGlobalRoot() { } async function startSubtest(subtest) { - await reportersSetup; + if (reportersSetup) { + // Only incur the overhead of awaiting the Promise once. + await reportersSetup; + reportersSetup = undefined; + } const root = getGlobalRoot(); if (!root.harness.bootstrapComplete) { diff --git a/test/fixtures/test-runner/output/default_output.js b/test/fixtures/test-runner/output/default_output.js index b0392f3737b1d6..3bb85c781ba7b1 100644 --- a/test/fixtures/test-runner/output/default_output.js +++ b/test/fixtures/test-runner/output/default_output.js @@ -9,7 +9,9 @@ const test = require('node:test'); test('should pass', () => {}); test('should fail', () => { throw new Error('fail'); }); test('should skip', { skip: true }, () => {}); -test('parent', () => { - test('should fail', () => { throw new Error('fail'); }); - test('should pass but parent fail', () => {}); +test('parent', (t) => { + t.test('should fail', () => { throw new Error('fail'); }); + t.test('should pass but parent fail', (t, done) => { + setImmediate(done); + }); }); diff --git a/test/fixtures/test-runner/output/default_output.snapshot b/test/fixtures/test-runner/output/default_output.snapshot index b003f9299c4418..d91db3bd9e54fe 100644 --- a/test/fixtures/test-runner/output/default_output.snapshot +++ b/test/fixtures/test-runner/output/default_output.snapshot @@ -17,6 +17,11 @@ *[39m *[39m *[39m + *[39m + *[39m + *[39m + *[39m + *[39m *[39m [31m✖ should pass but parent fail [90m(*ms)[39m[39m @@ -53,6 +58,11 @@ *[39m *[39m *[39m + *[39m + *[39m + *[39m + *[39m + *[39m *[39m *