test: deflake test runner timeout coverage

Use a dedicated fixture with a pending promise and assertion plan
instead of competing assertion timers. Keep both timeout failure
assertions and clear the keepalive interval after the tests finish.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/66255
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
Filip Skokan authored and Antoine du Hamel committed 2026-09-28 23:54:51 +02:00
1 parent cee8eb9c74
commit fb3d90a986
2 files changed
+12 -1

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
import test, { after } from 'node:test';
// Keep the event loop alive until both tests time out.
const interval = setInterval(() => {}, 1000);
after(() => clearInterval(interval));
test('pending promise', () => new Promise(() => {}));
test('pending assertion plan', (t) => {
t.plan(1, { wait: true });
});
+1 -1
View File
@@ -90,7 +90,7 @@ describe('require(\'node:test\').run', { concurrency: true }, () => {
it('should support timeout', async () => {
const stream = run({ timeout: 50, files: [
fixtures.path('test-runner', 'plan', 'timeout-basic.mjs'),
fixtures.path('test-runner', 'run-timeout.mjs'),
] });
stream.on('test:fail', common.mustCall((data) => {
assert.strictEqual(data.details.error.failureType, 'testTimeoutFailure');