question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Doesn't work with jest --projects switch

See original GitHub issue

Issue

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

https://github.com/clayne11/jest-projects-repro

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
clayne11commented, May 30, 2017
0reactions
kulshekharcommented, Oct 6, 2017

@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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found