jest config resolution within a mono repo
See original GitHub issueDo you want to request a feature or report a bug? feature
I have a mono repo (just like Jest itself) that hosts multiple npm packages. I want to be able to run jest
from anywhere within my repo and have it resolve to the jest.config.js
file in the root of my repo.
Right now, if i run jest
from within one of the package directories jest would try to resolve the config path and usually it ends up picking up one of the package.json
files on the way to the root.
for example (repro on Jest repo itself): current behaivor:
cd jest/packages/jest-cli
jest # resolves to `jest/packages/jest-cli/packages.json and fails to run the test because it's not a valid config
cd jest/
jest # resolves to `jest/package.json` and runs tests correctly
expected behaviour:
cd jest/packages/jest-cli/
jest # ignore `jest/packages/jest-cli/packages.json` and resolve to `jest/packages.json`
I don’t know what’s the best way to make it work without introducing a wrapper shell script (like we do at fb)
would adding a config option to ignore nested package.json
files be ok for this case?
like:
// jest.config.js
module.exports = {
ignoreNestedPackageJson: true,
};
the config resolution process will look like:
- traverse the directory tree up until a config file with
ignoreNestedPackageJson
is found - if # 1 is not found, resolve to the closest config
Issue Analytics
- State:
- Created 5 years ago
- Reactions:18
- Comments:6
Top GitHub Comments
Currently I solved my particular issue by using this VSCode launch task:
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. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.