Skip to content

Commit 1e7c852

Browse files
authored
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> PR-URL: #64051 Refs: https://github.com/nodejs/reliability/issues?q=%22test-runner-run-coverage%22 Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me>
1 parent 07e27ad commit 1e7c852

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

test/parallel/test-runner-run-coverage.mjs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,13 @@ describe('require(\'node:test\').run coverage settings', { concurrency: true },
154154
for await (const _ of stream);
155155
});
156156

157-
await it('should run with coverage and fail when below line threshold', async () => {
157+
await it('should run with coverage and fail when below line threshold', async (t) => {
158158
const thresholdErrors = [];
159159
const originalExitCode = process.exitCode;
160-
assert.notStrictEqual(originalExitCode, 1);
160+
t.after(() => {
161+
process.exitCode = originalExitCode;
162+
});
163+
process.exitCode = undefined;
161164
const stream = run({
162165
files,
163166
coverage: true,
@@ -178,7 +181,6 @@ describe('require(\'node:test\').run coverage settings', { concurrency: true },
178181
for await (const _ of stream);
179182
assert.deepStrictEqual(thresholdErrors.sort(), ['branch', 'function', 'line']);
180183
assert.strictEqual(process.exitCode, 1);
181-
process.exitCode = originalExitCode;
182184
});
183185
});
184186
});

0 commit comments

Comments
 (0)