[Bug]: jest.mock('package-name') does nothing
Version
3.3.2
Steps to reproduce
- Create any test file
- Mock any package that is used by dependencies of your project such as "node-fetch"
- Call jest.mock("package-name") at the top of your test file
- Run tests, observe that the package has NOT been mocked
Expected behavior
Packages should be mocked globally.
Actual behavior
Packages are not mocked at all.
Additional context
No response
Environment
System:
OS: macOS 12.6
CPU: (8) arm64 Apple M2
Binaries:
Node: 20.9.0 - ~/.nvm/versions/node/v20.9.0/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 10.8.0 - ~/.nvm/versions/node/v20.9.0/bin/npm
npmPackages:
jest: ^29.7.0 => 29.7.0
Hard to say something without looking at full reproduction. For instance, it can be that resetMocks is set to true in your Jest config.
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.
As noted in the Bug Report template, all bug reports requires a minimal reproduction. Please open up a new issue providing one. Read more at https://stackoverflow.com/help/minimal-reproducible-example.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.