Doesn't work with jest --projects switch
See original GitHub issueIssue
Jest 20.0 introduced a --projects
flag that allows the test-runner to run multiple projects each with their own independent configs with a single jest
instance, including watching. This is very helpful for developing monorepos as well as speeding up CI testing.
When using the --projects
flag, the tsconfig.json
file path is resolved relative to the project root rather than relative to the current project being tested.
Example
// from /workspace/project-root, with the following package structure
.
└── packages
├── package-1
└── package-2
jest --projects packages/package-1 packages/package-2
ENOENT: no such file or directory, open '/workspace/project-root/tsconfig.test.json'
Expected behavior
The __TS_CONFIG__
var needs to use <rootDir>
within it so that we can resolve each tsconfig.json
relative to the current project.
In this case we should be resolving the paths /workspace/project-root/packages/package-1/tsconfig.test.json
and /workspace/project-root/packages/package-2/tsconfig.test.json
.
Minimal reproduction
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Configuring Jest
Jest will run .mjs and .js files with nearest package.json 's type field set to module as ECMAScript Modules.
Read more >Jest 'projects' configuration does not read .babelrc and ...
1 Answer 1 · I've filed an issue with jest to include this functionality in babel-jest : github.com/facebook/jest/issues/6617. – Jürg Lehni · But ......
Read more >Should we be worried about Jest? : r/reactjs - Reddit
Serious question - if Jest works well and is the current standard, and one of the problems is that it's developed by one...
Read more >Test runner with Nodejs and Jest not working with 17.1
Create an empty Nodejs Console Application project · Install these npm packages with Dependency set to Development, Add to package. · Create a...
Read more >Angular CLI: “ng test” with Jest in 3 minutes - Just Jeb
In angular.json change @angular-devkit/build-angular:karma to @angular-builders/jest:run: "projects": ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Reproduction: https://github.com/clayne11/jest-projects-repro
@clayne11 I’ve pushed a change that I think should fix this issue. I’ve tested it against the sample repo and it seems to work (I had to add some content in each package’s tsconfig).
Would it be possible for you to test this (branch
fix-238
) on a real project as well?