You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Upgrade react-scripts to 2.0.0-next.66cc7a90.
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.
I tested this change, moving mocks from root to src/ works. Would that be okay? @TLadd
If you do yarn test --showConfig you'll see the root directory is configured to be src/ and according to the jest docs you referenced the mocks should be placed under the root dir.
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
node -v
: v9.8.0npm -v
: 5.6.0yarn --version
(if you use Yarn): 1.5.1npm ls react-scripts
(if you haven’t ejected): [email protected]Then, specify:
Steps to Reproduce
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.
The text was updated successfully, but these errors were encountered: