Skip to content

nodeMocks: absolute-path own loads and pnpm alias mocks differ from Jest #917

Open

Description

@danfry1

Problem

Under experimental.nodeMocks, two narrow cases still differ from Jest without a warning. Both were found in the review of #914.

  • A package's own load of a root-mocked file by absolute path gets the mock. Examples are require(path.join(__dirname, 'cid.js')), require(require.resolve('./cid')) and a file: URL import. Jest gives the real module, because getMockModule finds no mock for an absolute name. Only requests that start with . count as loads by file (node-registry.mjs:416-419).
  • With pnpm and a root mock under an npm alias, the real path names the original package. The copy check (node-registry.mjs:529-533) compares directory and spec names, so the mock no longer reaches every copy.

Done when

  • Each case either matches Jest or fails with a named error that names the module, and has a test.

Notes

Background: #897, #904, #914.

Activity

  1. added this to the 0.16.0 milestone on Nov 18, 2026
  2. added
    bug
    area:ownership
    area:jest-compat
    priority:low
    on Nov 18, 2026
  3. danfry1 commented on Nov 18, 2026

    @danfry1
    OwnerAuthor

    One more case from the review of #914. The hot-runtime verify error in src/jest-compat/setup.mjs:405 counts only entries.size + unresolved.size. When root mocks remain only by name (byName), it reports "0 jest.mock registrations remain" even though the registry is not empty. The count should include byName.size.

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

    area:jest-compatarea:ownershipbugpriority:low

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions