-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[BUG] jest.mock([moduleName]) not working with custom resolver specified #4985
Comments
This makes Jest 21+ unusable for our project and we're stuck with v20. Basically the auto jest.mock() functionality is not working at all; our existing tests started throwing things like i.e.:
|
Any suggestions on how to address this issue, would be happy to create a PR but not sure what the correct approach is here. Do anyone have examples on what this code path is supposed to do and why removing it would be the wrong solution? |
I'm not really sure what's wrong here. There was a similar bugfix to normal mock in #4489, maybe that can serve as inspiration? A failing test is also a great contribution, might be easier for others to jump in and help if there's already a test for it 🙂 |
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. |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Calling jest.mock([moduleName]) on an external module does not automatically mock the methods, but instead returns the actual methods within that module.
What is the expected behavior?
Calling jest.mock([moduleName]) on an external module should automatically mock out the methods in that module.
Please provide your exact Jest configuration and mention your Jest, node,
yarn/npm version and operating system.
This bug occurs in jest@21.0.0 and above, and does not occur in older versions of Jest.
I am running:
Please find an example of this bug illustrated in a repo found here.
This issue seems to be related to the following PR #4174 from @midzelis and merged by @cpojer and is a result of the following lines of code
Removing this block of code resolves this issue. I'm happy to open a PR for this, should it be the correct fix.
The text was updated successfully, but these errors were encountered: