Skip to content

[Feature]: Extend timer mocks to cover node:timers/promises #16392

Open

Description

@joshkel

🚀 Feature Proposal

Extend Jest's timer mocks (API docs) to cover Node.js's Timers Promises API.

Motivation

Jest's timer mocks (API docs) cover a large number of timer-related functions, but they don't cover Node.js's newer Timers Promises API. It would be great if those could be included as well.

Example

import * as tsp from 'node:timers/promises';

jest.useFakeTimers();

await tsp.setTimeout(1000);

Pitch

Currently, some code under test can do what seems like a harmless refactor from global setTimeout to node:timers/promises setTimeout and suddenly find itself no longer covered by Jest's timer mocks. And the source of the shortfall is much less obvious than when the tests are calling jest.mock or jest.spyOn themselves.

Activity

  1. github-actions commented on Sep 20, 2026

    @github-actions

    This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

  2. joshkel commented on Sep 21, 2026

    @joshkel
    ContributorAuthor

    Not stale.

  3. github-actions commented on Oct 21, 2026

    @github-actions

    This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

  4. joshkel commented on Oct 21, 2026

    @joshkel
    ContributorAuthor

    Not stale.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions