Skip to content

--test-timeout behavior bug #57656

Closed
@brianwestphal

Description

@brianwestphal

Version

22.14.0

Platform

Darwin 24.3.0 Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:16 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6000 arm64

Subsystem

No response

What steps will reproduce the bug?

The --test-timeout flag passed to node seems to affect the module level rather than the individual tests, which doesn't make a lot of sense.

For example, with a test file like:

import { it } from "node:test";

const sleep = (durationMSec) => new Promise((resolve) => setTimeout(resolve, durationMSec));

it("bla1", async () => {
  await sleep(7000);
});
it("bla2", async () => {
  await sleep(7000);
});

run with node --test --test-timeout=10000 vs node --test --test-timeout=20000

Each test takes about 7000ms to run, so they should each pass and the module should pass, with either test-timeout value. However, in fact, the 10000 test-timeout value fails because the module as a whole takes longer than 10000ms.

How often does it reproduce? Is there a required condition?

Every time with the above conditions

What is the expected behavior? Why is that the expected behavior?

The --test-timeout flag should affect the individual tests and not the modules. Otherwise, you'd need to know how many tests you were planning to write ahead of time, which doesn't make sense.

What do you see instead?

Image

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.test_runnerIssues and PRs related to the test runner subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions