fix(jest): scope coverage output per-project in multi-project workspaces (fixes #1009)#2212
Open
just-jeb wants to merge 3 commits into
Open
fix(jest): scope coverage output per-project in multi-project workspaces (fixes #1009)#2212just-jeb wants to merge 3 commits into
just-jeb wants to merge 3 commits into
Conversation
1194137 to
21eccdd
Compare
Owner
Author
|
Potentially breaking? |
21eccdd to
426d01c
Compare
…isions (#1009) When running ng test in a multi-project Angular workspace, each project's coverage output was written to the same directory (e.g. root ./coverage/), causing each successive run to overwrite the previous project's coverage report. Fix: set coverageDirectory in DefaultConfigResolver.resolveForProject() to <projectRoot>/coverage so each Angular project's coverage lands in its own isolated output directory. This is a project-level default that can still be overridden per-project via the jest.config.js customization mechanism. Also removes erroneous debug console.log statements from jest-configuration-builder.ts and fixes the scopeOutputDirectoriesForProjects approach, which incorrectly mutated the Jest 'projects' array (breaking --find-related-tests and project path resolution). Adds: unit test for coverageDirectory scoping, integration test validate-coverage.js
426d01c to
4f6f462
Compare
Owner
Author
|
Re: 'Potentially breaking?' Yes — it changes coverage output from Already labeled |
…l integration test The unit test asserting config.coverageDirectory field value is an implementation detail check. The behavioral proof — that coverage files actually land under projects/<name>/coverage/ on disk — is covered by the integration test in validate-coverage.js. Remove the unit test to avoid false confidence from a config-shape assertion.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR Checklist
PR Type
What is the current behavior?
In multi-project workspaces, all projects write Jest coverage output to the same workspace-root
coverage/directory. When projects run in sequence (ng test project-a --coverage; ng test project-b --coverage), the second run overwrites the first. There is no way to get coverage for multiple projects simultaneously.Issue Number: #1009
What is the new behavior?
coverageDirectoryis set unconditionally in the per-project default config to<projectRoot>/coverage. For a standardng newsingle-project workspace,projectRoot === workspaceRoot, so output stays at./coverage— no change. For multi-project workspaces, each project writes to its ownprojects/<name>/coveragedirectory.Users can still override via their own
jest.config.ts(the per-project user layer is merged last).Does this PR introduce a breaking change?
Standard single-project workspaces (
ng new) are unaffected. Multi-project workspaces previously had broken behavior (overwriting). The only behavior change for users is the library-only workspace whereprojectRootis not the workspace root — those will see coverage at<projectRoot>/coverageinstead of./coverage. Will be called out in CHANGELOG.Other information
N/A