You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
nodeMocks: absolute-path own loads and pnpm alias mocks differ from Jest #917
area:jest-compatjest-compat layer, jest.mock and migration from Jestarea:ownershipWhich side (Node or Vite) loads a module; double instances, aliases, mocks reaching Node codebugSomething isn't workingpriority:lowNice to have
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.
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.
area:jest-compatjest-compat layer, jest.mock and migration from Jestarea:ownershipWhich side (Node or Vite) loads a module; double instances, aliases, mocks reaching Node codebugSomething isn't workingpriority:lowNice to have
Activity
danfry1 commentedon Nov 18, 2026
One more case from the review of #914. The hot-runtime verify error in
src/jest-compat/setup.mjs:405counts onlyentries.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 includebyName.size.