Skip to content

Commit 44debf0

Browse files
committed
fixup! test_runner: validate timeout option
1 parent f0835f7 commit 44debf0

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/internal/test_runner/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function testTimeout(promise, timeout) {
5151
return promise;
5252
}
5353
return SafePromiseRace([
54-
promise,
54+
PromiseResolve(promise),
5555
PromisePrototypeThen(setTimeout(timeout, null, { ref: false }), () => {
5656
throw new ERR_TEST_FAILURE(
5757
`test timed out after ${timeout}ms`,

test/parallel/test-runner-option-validation.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ const assert = require('assert');
44
const test = require('node:test');
55

66
[Symbol(), {}, [], () => {}, 1n, true, '1'].forEach((timeout) => {
7-
assert.throws(() => test('name', { timeout }), { code: 'ERR_INVALID_ARG_TYPE' });
7+
assert.throws(() => test({ timeout }), { code: 'ERR_INVALID_ARG_TYPE' });
88
});
9-
[-1, 2 ** 33, 1.1].forEach((timeout) => {
10-
assert.throws(() => test('name', { timeout }), { code: 'ERR_OUT_OF_RANGE' });
9+
[-1, 2 ** 33, 1.1, -Infinity, NaN].forEach((timeout) => {
10+
assert.throws(() => test({ timeout }), { code: 'ERR_OUT_OF_RANGE' });
1111
});
1212
[null, undefined, Infinity, 0, 1].forEach((timeout) => {
1313
// Valid values should not throw.
14-
test('name', { timeout });
14+
test({ timeout });
1515
});

0 commit comments

Comments
 (0)