-
-
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
Mocking modules and __mocks__/<module>/index.js #4439
Comments
@hongymagic was it a typo:
|
Just came across this. Still a bug in |
Definitely a bug. Dug a bit into it, and the issue is that when the resolver queries the module map for mocks here: https://github.com/facebook/jest/blob/f4f51914d577dc53748f599f3f626dfe3154883e/packages/jest-resolve/src/index.js#L230, the mock is saved as I'm not sure how to fix it though. Help welcome! |
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?
Potential bug as described behaviour below could be intentional.
What is the current behavior?
If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can
yarn install
andyarn test
.Currently when creating a mock for modules, you can add it to root
__mocks__
directory. And it also supports sub-modules like so:However it fails to recognise the same
LOAD_INDEX
(or even perhapsLOAD_AS_DIRECTORY
resolver behaviour as documented in Node.js documentation. For example, this won't work:Couldn't or didn't know how to create a global mock on
repl.it
so here's a contrived example:throws
However if I do this it works as expected:
What is the expected behavior?
Jest recognises
__mocks__/twilio/index.js
as moduletwilio
. I understand that the current behaviour could be intentional, in which case we should proceed by documenting it.Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
The text was updated successfully, but these errors were encountered: