Skip to content

node_modules Mocks are not picked up by jest with latest react-scripts #7539

Open
@tomitrescak

Description

@tomitrescak

Describe the bug

When upgrading from react-scripts@3.0.1 to latest the mocks are no longer picked up from /__mocks__ directory

Did you try recovering your dependencies?

YES

Which terms did you search for in User Guide?

jest manual mocks broken

Environment

Environment Info:

System:
OS: macOS 10.14.5
CPU: (8) x64 Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz
Binaries:
Node: 12.8.0 - /usr/local/bin/node
Yarn: 1.17.3 - ~/.yarn/bin/yarn
npm: 6.10.2 - /usr/local/bin/npm
Browsers:
Chrome: 76.0.3809.100
Firefox: 68.0.1
Safari: 12.1.1
npmPackages:
react: ^16.9.0 => 16.9.0
react-dom: ^16.9.0 => 16.9.0
react-scripts: 3.1.1 => 3.1.1
npmGlobalPackages:
create-react-app: 2.1.3

Steps to reproduce

(Write your steps here:)

  1. create a manual mock of any node_modules package
  2. put it to mocks directory
  3. run your test

Expected behavior

Mocks are picked up by jest

Actual behavior

Mocks are not picked up

Reproducible demo

(Paste the link to an example project and exact instructions to reproduce the issue.)

  1. git clone https://github.com/tomitrescak/react-boilerplate -b Demo
  2. cd react-boilerplate
  3. yarn
  4. yarn test
  5. p -> 'button'
  6. error: Trans not found (not being picked up by mocks)

To see that is works with previous react-scripts do

  1. yarn add react-scripts@3.0.1
  2. yarn test
  3. You will recieve a snapshot erro which is fine

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions