From d73ab26e91e40fd858928bee95658fc60ce96994 Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Sun, 21 Jun 2026 16:08:53 -0700 Subject: [PATCH] test: fix flaky test-runner coverage threshold test Reset process.exitCode before running the coverage threshold check. This lets the test verify the exit code set by that run() call without depending on process-global state from earlier coverage runs. Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com> --- test/parallel/test-runner-run-coverage.mjs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-runner-run-coverage.mjs b/test/parallel/test-runner-run-coverage.mjs index 89a9da2a179e44..5a70644a89d93c 100644 --- a/test/parallel/test-runner-run-coverage.mjs +++ b/test/parallel/test-runner-run-coverage.mjs @@ -154,10 +154,13 @@ describe('require(\'node:test\').run coverage settings', { concurrency: true }, for await (const _ of stream); }); - await it('should run with coverage and fail when below line threshold', async () => { + await it('should run with coverage and fail when below line threshold', async (t) => { const thresholdErrors = []; const originalExitCode = process.exitCode; - assert.notStrictEqual(originalExitCode, 1); + t.after(() => { + process.exitCode = originalExitCode; + }); + process.exitCode = undefined; const stream = run({ files, coverage: true, @@ -178,7 +181,6 @@ describe('require(\'node:test\').run coverage settings', { concurrency: true }, for await (const _ of stream); assert.deepStrictEqual(thresholdErrors.sort(), ['branch', 'function', 'line']); assert.strictEqual(process.exitCode, 1); - process.exitCode = originalExitCode; }); }); });