Skip to content

salto-io/jest_projects_coverage_issue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sample repo for Jest issue #9628

Jest projects and collectCoverageFrom do not work together.

Structure

This monorepo contains two packages - add and mul.

Both packages have an index.js file at their root.

Package add is configured to test coverage for its index.js.

Package mul is configured not to test coverage for its index.js.

When running jest (or yarn test) at each package's root, Jest behaves correctly - tests coverage for add's index.js and does not test coverage for mul's index.js.

The problem is when running jest (or yarn test) at the repo root, using the projects feature.

Reproducing the issue

Clone the repo and run yarn at the root.

Then run yarn test or yarn test2 (see below).

Expected behavior

When using projects, we should be able to configure Jest to exclude index.js at package mul while including index.js at package add.

Actual behavior

There is no way to configure the above.

Attempt 1 - inherit collectCoverageFrom

Run yarn test.

This uses jest.config.json which does not specify collectCoverageFrom.

Result: Coverage is collected from both packages.

Attempt 2 - specify collectCoverageFrom with package paths

Run yarn test2.

This uses jest.config.2.json which specifies collectCoverageFrom.

Result: Coverage is not collected from any package.

Same result when specifying the full path in collectCoverageFrom

About

Demonstrate Jest issue 9628 with projects and collectCoverageFrom

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published