-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Jest's require looks for modules in different order than Node.js #5377
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
Comments
Could you send a PR with a fix and test? The implementation is here: https://github.com/facebook/jest/blob/79086eedaaec453d99002971680e55f560072a29/packages/jest-runtime/src/index.js#L270-L336 |
Hi, I made a fork and tried running the tests before I made any changes (as described in "contributing" docs here) and this was the output:
Is this...not ok, but at least expected? |
That's not expected... Are you on the latest version of yarn (1.3.2)? If yes, can you pass |
PR sent |
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?
Jest looks for modules first in
modulePaths
and then innode_modules
folderIf 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
.yarn install
yarn test
What is the expected behavior?
Jest would firstly look for modules in
node_modules
and then inmodulePaths
. It works this way in classic Node.js - first look innode_modules
and then inNODE_PATH
.Therefore
console.log
indummy.test.js
should print<rootDir>/node_modules/passport/lib/index.js
. But it prints<rootDir>/config/passport.js
Please provide your exact Jest configuration and mention your Jest, node,
yarn/npm version and operating system.
Jest - 22.1.4
node - 6.12.2
yarn - 1.3.2
npm - 3.10.10
OS - Ubuntu 16.04.3 LTS
The text was updated successfully, but these errors were encountered: