Skip to content

test_runner: add timeout for tests #43490

Description

@MoLow

What is the problem this feature will solve?

currently - tests can easily be stuck or never end, which makes it very hard to understand and locate where your problem might originate

for example, this program will be very hard to debug:

test('top level', { concurrency: 2 }, async (t) => {
  await t.test('endless', () => new Promise(() => {
    setTimeout(() => {}, /* Large number */);
  }));


  // ... many other tests
});

What is the feature you are proposing to solve the problem?

add a timeout to tests running via node:test, I propose adding a default timeout that will be configurable
one of the most important parts of testing is failing fast and knowing what the failure is, and timing out will help determine which test is misfunctioning

What alternatives have you considered?

No response

Activity

  1. MoLow commented on Jun 19, 2022

    @MoLow
    MemberAuthor

    CC @benjamingr Please ping relevant people and add a label?

  2. VoltrexKeyva commented on Jun 19, 2022

    @VoltrexKeyva
    Contributor

    @nodejs/test_runner

  3. benjamingr commented on Jun 19, 2022

    @benjamingr
    Member

    Yes, this is a good idea and I am in favor. Is this something you'd like to work on?

  4. MoLow commented on Jun 19, 2022

    @MoLow
    MemberAuthor

    Yes, this is a good idea and I am in favor. Is this something you'd like to work on?

    Yes, assuming no objections

  5. cjihrig commented on Jun 19, 2022

    @cjihrig
    Contributor

    No objections - this is something we should definitely support.

  6. added a commit that references this issue on Jul 20, 2022
  7. added a commit that references this issue on Jul 31, 2022
  8. bitflower commented on Jul 10, 2023

    @bitflower

    Has this been implemented?

  9. benjamingr commented on Jul 19, 2023

    @benjamingr
    Member

    Yeah there is a timeout parameter now check the test runner docs. @bitflower

  10. bitflower commented on Jul 19, 2023

    @bitflower

    Thanks for the feedback @benjamingr ! Sorry to not report back. I had found it in the meantime (it's different to e.g. mocha).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues requesting new Node.js features.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