Skip to content

Jest Manual Mocks stop working react-scripts v2 #4344

Closed
@TLadd

Description

@TLadd

Is this a bug report?

Yes

Did you try recovering your dependencies?

Yes

Which terms did you search for in User Guide?

Manual Mocks

Environment

  1. node -v: v9.8.0
  2. npm -v: 5.6.0
  3. yarn --version (if you use Yarn): 1.5.1
  4. npm ls react-scripts (if you haven’t ejected): [email protected]

Then, specify:

  1. Operating system: macOS High Sierra
  2. Browser and version (if relevant): N/A

Steps to Reproduce

  1. Create a new project with create-react-app.
  2. Write a jest test that makes use of manual mocks. Ensure the test passes and that the mocked value is being used in the test.
  3. Upgrade react-scripts to 2.0.0-next.66cc7a90.
  4. Run the tests again and observe that the test no longer uses the mocked value

Expected Behavior

Jest manual mocks should still take effect

Actual Behavior

Jest manual mocks no longer work

Reproducible Demo

https://github.com/TLadd/manual-mocks-cra-test
The master branch is a newly-created CRA app and uses react-scripts 1.1.4. The only change is adding lodash.uniqueid as a dependency to the project, a src/uniqueId.js, src/tests/uniqueId.js, and mocks/lodash.uniqueid.js. The test just ensures that lodash.uniqueid returns the mocked value setup in mocks/lodash.uniqueid.js. The test passes on master.

On branch react-scripts-v2, the only change made is to update to [email protected], and now the test fails. The mocks is no longer taking effect.

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