jest icon indicating copy to clipboard operation
jest copied to clipboard

[Bug]: jest.mock('package-name') does nothing

Open Tyguy7 opened this issue 1 year ago • 2 comments

Version

3.3.2

Steps to reproduce

  1. Create any test file
  2. Mock any package that is used by dependencies of your project such as "node-fetch"
  3. Call jest.mock("package-name") at the top of your test file
  4. 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

Tyguy7 avatar May 30 '24 20:05 Tyguy7

Hard to say something without looking at full reproduction. For instance, it can be that resetMocks is set to true in your Jest config.

mrazauskas avatar May 31 '24 10:05 mrazauskas

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.

github-actions[bot] avatar Jun 30 '24 11:06 github-actions[bot]

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.

github-actions[bot] avatar Jun 30 '24 12:06 github-actions[bot]

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.

github-actions[bot] avatar Aug 02 '24 00:08 github-actions[bot]