Skip to content

Commit d73ab26

Browse files
committed
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>
1 parent 1f806f2 commit d73ab26

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)