Skip to content

Commit 04f280b

Browse files
committed
fixup! address more comments
1 parent 24a1936 commit 04f280b

File tree

2 files changed

+13
-21
lines changed

2 files changed

+13
-21
lines changed

lib/internal/test_runner/test.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -605,17 +605,15 @@ class Test extends AsyncResource {
605605
throw new ERR_INVALID_ARG_TYPE('options.concurrency', ['boolean', 'number'], concurrency);
606606
}
607607

608-
// Take timeout from cli
609-
const cliTimeout = this.config.timeout;
610-
if (cliTimeout != null && cliTimeout !== Infinity) {
611-
validateNumber(cliTimeout, 'options.timeout', 0, TIMEOUT_MAX);
612-
this.timeout = cliTimeout;
613-
}
614-
615-
// Take timeout from options
616608
if (timeout != null && timeout !== Infinity) {
617609
validateNumber(timeout, 'options.timeout', 0, TIMEOUT_MAX);
618610
this.timeout = timeout;
611+
} else {
612+
const cliTimeout = this.config.timeout;
613+
if (cliTimeout != null && cliTimeout !== Infinity) {
614+
validateNumber(cliTimeout, 'options.timeout', 0, TIMEOUT_MAX);
615+
this.timeout = cliTimeout;
616+
}
619617
}
620618

621619
if (skip) {
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
11
// Flags: --test-timeout=20
22
'use strict';
3-
const { describe, test, afterEach } = require('node:test');
3+
const { describe, test } = require('node:test');
44
const { setTimeout } = require('node:timers/promises');
55

6-
let timeout;
7-
86
describe('--test-timeout is set to 20ms', () => {
97
test('should timeout after 20ms', async () => {
10-
timeout = await setTimeout(2000);
8+
await setTimeout(200000, undefined, { ref: false });
119
});
1210
test('should timeout after 5ms', { timeout: 5 }, async () => {
13-
timeout = await setTimeout(2000);
14-
});
15-
test('should not timeout', { timeout: 5000 }, async () => {
16-
await setTimeout(200);
11+
await setTimeout(200000, undefined, { ref: false });
1712
});
18-
test('should pass', async () => {});
1913

20-
afterEach(() => {
21-
if (timeout) {
22-
timeout.unref();
23-
}
14+
test('should not timeout', { timeout: 50000 }, async () => {
15+
await setTimeout(1);
2416
});
17+
18+
test('should pass', async () => {});
2519
});

0 commit comments

Comments
 (0)