-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Closed
Labels
Description
Version
30.0.0
Steps to reproduce
- Clone https://github.com/joshkel/jest-automock-custom-resolver
npm i
npm test
Expected behavior
Successful test completion
Actual behavior
FAIL ./test.ts
● Test suite failed to run
Cannot find module 'node:child_process' from 'test.ts'
> 1 | import { spawn } from 'node:child_process';
| ^
2 |
3 | jest.mock('node:child_process');
4 |
at Resolver._throwModNotFoundError (node_modules/jest-resolve/build/index.js:868:11)
at Object.<anonymous> (test.ts:1:1)
Additional context
From what I can tell, this bug only happens if the following are all true:
- Mocking a built-in Node.js module
- Using automock (i.e., not specifying a factory function)
- Using a custom resolver (even if all that resolver does is call the default resolver)
Environment
System:
OS: macOS 15.5
CPU: (10) arm64 Apple M1 Pro
Binaries:
Node: 22.15.0 - ~/.nvm/versions/node/v22.15.0/bin/node
Yarn: 1.22.22 - /opt/homebrew/bin/yarn
npm: 10.9.2 - ~/.nvm/versions/node/v22.15.0/bin/npm
bun: 1.2.15 - /opt/homebrew/bin/bun
npmPackages:
jest: ^30.0.0 => 30.0.0
finkinfridom, ridesz and spanishpear