-
-
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
rootDir points to the folder that contains jest-config #3613
Comments
I can confirm having exactly the same problem when upgrading from Jest 19 to Jest 20. I'm using macOS 10.12.4, but for my team members using Windows, the "Validation Error" reporting the path which can't be resolved isn't displayed. |
I added |
Awesome, thanks @bhouser! Adding a |
Appears to be a bug where it gets the wrong `rootDir` in versions `20` and up. Discovered a workaround that fixes the issue, though it appears to be a bug. jestjs/jest#3613 (comment)
|
@redonkulus for that use |
This is documented behavior (#4726) |
For shared Jest configuration, a base config file somewhere in the root is a good option. You can even export a function there that accepts the root dir of the subproject and sets it as the module.exports = require('../../config/jest/base.config.js')(__dirname); |
Just to let you know I was researching for hours to find this answer. Very helpful, thanks! Maybe worth a dedicated/prominent section in the docs - since it's quite a common case to do multi-root and currently takes a lot of research to find the answer. |
Happy to accept a PR for this! :) |
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. |
<rootDir>
points to the folder that contains jest-config instead of the root of the directory containing thepackage.json
or thepwd
if nopackage.json
is foundDo you want to request a feature or report a bug?
Bug
What is the current behavior?
<rootDir>
gets replaced with the path to the folder that contains config file.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
.That works fine when your jest config lives in root dir, but if you place your jest config in a different folder (say
test
) then config paths will be wrong because a<rootDir>/src
will be transformed into/myproj/test/src
instead ofmyproj/src
.What is the expected behavior?
As per documentation (and behaviour in 19):
Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
Jest: 20.0.3
Node: v7.5.0
NPM 4.1.2
macOS 10.12.4
jestConfig:
running with
jest --config test/jest-config.json --forceExit --coverage
The text was updated successfully, but these errors were encountered: