fix: projects should use collectCoverageFrom option #15249
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TL;DR; running a single project defined in the
projects
config option fails to correctly use thecollectCoverageFrom
config option for that project.Summary
I upgraded my
nx
repo to 19 and attempted to migrate from groups of tests defined as configurations inproject.json
, to using jestprojects
.However, when I would run a single
jest
project, it would report the code coverage for the wholenx
project instead of only the source code files being tested. This resulted in a non-zero exit code, causingnx
to not cache the results (even when all the tests that ran passed).I tried again with a non-mono repo and got the same result.
From what I can tell, a project config is meant to be nearly identical to the overall config, including using collectCoverageFrom.
I wrote up some tests to illustrate this behavior.
I left comments in the test file
PROJECT_COVERAGE_BUG_NOTE
where the tests are failing, but ought to be passing.While writing these tests, I came across some unexpected behavior. The stderr was missing some text I'd have expected, and when I ran it manually the text was present. I commented those out and left a
POSSIBLE_BUG_NOTE
comment.Test plan
I wrote tests to check combinations of
jest
config vs nottestPathPattern
in the cli arguments vs notcollectCoverageFrom
in the cli arguments vs not (Contrasts how when the option is defined in a single project it is ignored)Those tests can be run by
TODO
This is a draft, providing tests to check if all works as expected. What remains:
describe.only
dir
toDIR