Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test_runner: fix timeout not propagated to the child process in run
  • Loading branch information
jakecastelli committed Jun 25, 2025
commit a11e81689395a7e3d6366272f67f02786913783a
4 changes: 4 additions & 0 deletions lib/internal/test_runner/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ function getRunArgs(path, { forceExit,
only,
argv: suppliedArgs,
execArgv,
root: { timeout },
cwd }) {
const argv = ArrayPrototypeFilter(process.execArgv, filterExecArgv);
if (forceExit === true) {
Expand All @@ -162,6 +163,9 @@ function getRunArgs(path, { forceExit,
if (only === true) {
ArrayPrototypePush(argv, '--test-only');
}
if (timeout != null) {
ArrayPrototypePush(argv, `--test-timeout=${timeout}`);
}

ArrayPrototypePushApply(argv, execArgv);

Expand Down
6 changes: 4 additions & 2 deletions test/parallel/test-runner-run.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ describe('require(\'node:test\').run', { concurrency: true }, () => {

it('should support timeout', async () => {
const stream = run({ timeout: 50, files: [
fixtures.path('test-runner', 'timeout-basic.mjs'),
fixtures.path('test-runner', 'plan', 'timeout-basic.mjs'),
] });
stream.on('test:fail', common.mustCall(1));
stream.on('test:fail', common.mustCall((data) => {
assert.strictEqual(data.details.error.failureType, 'testTimeoutFailure');
}));
stream.on('test:pass', common.mustNotCall());
// eslint-disable-next-line no-unused-vars
for await (const _ of stream);
Expand Down