diff --git a/lib/internal/test_runner/harness.js b/lib/internal/test_runner/harness.js index 84205d43ac78f9..3d4fc3b49674c5 100644 --- a/lib/internal/test_runner/harness.js +++ b/lib/internal/test_runner/harness.js @@ -178,13 +178,14 @@ function getGlobalRoot() { globalRoot.reporter.once('test:fail', () => { process.exitCode = kGenericUserError; }); - reportersSetup = setupTestReporters(globalRoot.reporter); + reportersSetup = setupTestReporters(globalRoot); } return globalRoot; } async function startSubtest(subtest) { await reportersSetup; + getGlobalRoot().harness.bootstrapComplete = true; await subtest.start(); } diff --git a/lib/internal/test_runner/runner.js b/lib/internal/test_runner/runner.js index 5108fc3283f63b..5b772251be981e 100644 --- a/lib/internal/test_runner/runner.js +++ b/lib/internal/test_runner/runner.js @@ -387,13 +387,16 @@ function run(options) { filesWatcher = watchFiles(testFiles, root, inspectPort); postRun = undefined; } - const runFiles = () => SafePromiseAllSettledReturnVoid(testFiles, (path) => { - const subtest = runTestFile(path, root, inspectPort, filesWatcher); - runningSubtests.set(path, subtest); - return subtest; - }); + const runFiles = () => { + root.harness.bootstrapComplete = true; + return SafePromiseAllSettledReturnVoid(testFiles, (path) => { + const subtest = runTestFile(path, root, inspectPort, filesWatcher); + runningSubtests.set(path, subtest); + return subtest; + }); + }; - PromisePrototypeThen(PromisePrototypeThen(PromiseResolve(setup?.(root.reporter)), runFiles), postRun); + PromisePrototypeThen(PromisePrototypeThen(PromiseResolve(setup?.(root)), runFiles), postRun); return root.reporter; } diff --git a/lib/internal/test_runner/utils.js b/lib/internal/test_runner/utils.js index 72270e464248a5..e4fd23c8e8cb60 100644 --- a/lib/internal/test_runner/utils.js +++ b/lib/internal/test_runner/utils.js @@ -150,13 +150,13 @@ async function getReportersMap(reporters, destinations) { } -async function setupTestReporters(testsStream) { +async function setupTestReporters(rootTest) { try { const { reporters, destinations } = parseCommandLine(); const reportersMap = await getReportersMap(reporters, destinations); for (let i = 0; i < reportersMap.length; i++) { const { reporter, destination } = reportersMap[i]; - compose(testsStream, reporter).pipe(destination); + compose(rootTest.reporter, reporter).pipe(destination); } } catch (err) { throw new ERR_TEST_FAILURE(err, kAsyncBootstrapFailure);