-
-
Notifications
You must be signed in to change notification settings - Fork 27k
Allow node_modules to be mocked as described in the Jest documentation #8257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Allow node_modules to be mocked as described in the Jest documentation #8257
Conversation
Hi KennethSundqvist! Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file.In order for us to review and merge your code, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Hi there! Is the only thing left here for this change to be reviewed? |
If this fix is ready, my team and I would be very grateful to have this merged. This has caused us some pain and effort working through alternative mocking solutions while module mocks have been broken. Thank you for all of the great work and we hope to see this fix released soon! |
Hello, isn’t this PR ready to be merged? I have been waiting for this fix in CRA for cleaner jest config in my project |
I cannot automatically mock |
Can this be merged please? |
@bugzpodder @ianschmitz Looking at the PR that caused this bug, #7480 and the related issue #7458. The time from raising the issue (August 1st 2019) to merging the PR (August 6th 2019) was a mere five days. From the time the PR got open (August 5th 2019) to closing was only one day! Reading through both threads, it looks a lot like there was a slowdown for ONE person, and this was immediately rubber-stamped and merged without questioning the breaking changes to documented jest usage. Compare this to #7539. Opened just ten days later! Cosigned by nearly a dozen people. Reverting the change from #7480 got blown off, so here we are with a fix, and it's been languishing for nearly a year. Over a year, if you count from the moment the issue was opened. Nobody had to line up and say please to get the breaking change in... and a year later there's still no documentation that jest's defaults have been radically changed. Furthermore, I'd argue that optimizing a CPU bottleneck at the expense of developer time spent chasing undocumented bugs is a pretty alarming trade-off. |
This PR fixes #7539.
The Jest documentation says:
We have to check if the directory exists before we add it because the watcher used by Jest (
jest-haste-map
>'./lib/FSEventsWatcher.js'
>walker
) will throw an error if'<rootDir>/__mocks__'
doesn't exist.