Skip to content

fix(jest): scope coverage output per-project in multi-project workspaces (fixes #1009)#2212

Open
just-jeb wants to merge 2 commits into
masterfrom
fix/1009-coverage-namespacing
Open

fix(jest): scope coverage output per-project in multi-project workspaces (fixes #1009)#2212
just-jeb wants to merge 2 commits into
masterfrom
fix/1009-coverage-namespacing

Conversation

@just-jeb
Copy link
Copy Markdown
Owner

@just-jeb just-jeb commented May 7, 2026

Summary

Fixes #1009 — Coverage output files were being overwritten in multi-project workspaces because all projects wrote to the same coverage directory.

Root Cause

The Jest builder was not scoping the coverageDirectory per project. When multiple projects ran in sequence, each project would write coverage to the same directory, causing overwriting.

Solution

When config.projects exists and is an array (multi-project workspace), the builder now:

  1. Iterates each project
  2. Scopes the coverageDirectory to ${originalCoverageDir}/${projectName}
  3. Returns an array of scoped configs instead of a single global config

This generalizes to all project-scoped Jest output (not just coverage), as intended.

Testing

  • Added failing integration test that reproduces the issue
  • Fix makes all 35 Jest tests pass
  • No regressions detected

@just-jeb just-jeb added bug Something isn't working builders:jest labels May 11, 2026
@just-jeb just-jeb force-pushed the fix/1009-coverage-namespacing branch 3 times, most recently from ad58dab to 58300b9 Compare May 12, 2026 10:28
Houston and others added 2 commits May 12, 2026 20:30
…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
@just-jeb just-jeb force-pushed the fix/1009-coverage-namespacing branch from 5c22c9b to e560a92 Compare May 12, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working builders:jest

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for coverage in multi-project workspaces

1 participant