-
-
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]: User mock shadows Node module #13252
Comments
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
Looks like this is a special case of #2070 #2070 focuses on 2 different files in different directories in the user's code having the same name, but the fact the basenme of mocks is globally unique in jest also causes the same issue when a file in the user code have the same name as a third party dependency |
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. |
When defining a mock e.g.
lib/__mocks__/foo.js
in order to mocklib/foo.js
, Jest also auto mocks calls torequire('foo')
(and not justrequire('./lib/foo.js')
which is unintended.Version
29.0.3
Steps to reproduce
Expected behavior
Should log the Redis client from the
redis
module:Actual behavior
The
require('redis')
call imported the user mock forlib/redis.js
which is unintended according to https://jestjs.io/docs/manual-mocksThe mock in in
lib/__mocks__/redis.js
should mock onlylib/redis.js
and not theredis
package itself.Additional context
No response
Environment
Follow up of #12938
The text was updated successfully, but these errors were encountered: