Merge coverage reports from shards: Vitest, Jest and coverage.py
Each way to combine shard coverage in Vitest, Jest and coverage.py, measured, including the ones that lose a shard without an error.

Run each shard with its own output, then merge the raw data, not the
summaries. In Vitest, write blob reports and run vitest --merge-reports --coverage. In Jest, put each shard’s coverage-final.json in one folder,
then run nyc merge and nyc report. In Python, run coverage combine with a
[paths] mapping.

Merge commands at a glance
| Runner | Each shard | Then |
|---|---|---|
| Vitest | vitest run --coverage --reporter=blob --shard=1/2 | vitest --merge-reports --coverage |
| Jest | jest --coverage --shard=1/2 --coverageDirectory=coverage/shard-1 | Copy coverage-final.json files into one folder, nyc merge, nyc report |
| coverage.py | coverage run with parallel = true, or rename .coverage per job | coverage combine, with [tool.coverage.paths] |
We measured each with two shards of a small project, one testing pricing
and one testing shipping: Vitest 5.1.0 with the V8 provider, Jest 30.5.2
with nyc 18, and coverage.py 7.17.2 with pytest-cov 7.1.0. Each correct merge
matched a single run of all the tests.

Vitest: blob reports and –merge-reports
vitest run --coverage --reporter=blob --shard=1/2
vitest run --coverage --reporter=blob --shard=2/2
vitest --merge-reports --coverage
Each shard writes .vitest/blob/blob-1-2.json and blob-2-2.json. The merge
reported 5 of 6 lines, the same as one full run. In CI, upload .vitest/blob
from every job and download them all into that folder before merging.
| What we tried | What happened |
|---|---|
Two shards with --coverage, no blob | coverage/ held only the last shard: 2 of 6 lines |
Blob shards without --coverage | Merge wrote an empty report, and exited 0 |
--merge-reports without --coverage | No merged coverage; coverage/ still held shard 2 |
Both shards writing --outputFile=.vitest/blob/blob-1.json | One overwrote the other: 2 of 6 lines |
Jest: nyc merge
Jest has no merge command. Write each shard’s coverage to its own folder,
then merge the coverage-final.json files with nyc:
jest --coverage --shard=1/2 --coverageDirectory=coverage/shard-1
jest --coverage --shard=2/2 --coverageDirectory=coverage/shard-2
mkdir -p shards merged
cp coverage/shard-1/coverage-final.json shards/shard-1.json
cp coverage/shard-2/coverage-final.json shards/shard-2.json
nyc merge shards merged/coverage-final.json
nyc report --temp-dir merged --reporter=lcov --reporter=text
This reported 7 of 8 lines, the same as one run. Copying the files straight
into .nyc_output and running nyc report worked too.
| What we tried | What happened |
|---|---|
Two shards in the default coverage/ | The second overwrote the first: 4 of 8 lines |
nyc merge coverage with the shard files in subfolders | Exit 0, empty report: it reads only the top folder |
| Both files copied under one name | One shard lost: 4 of 8 lines |
nyc merge on coverage-summary.json files | “Invalid file coverage object”, exit 1 |
Keep json in coverageReporters: coverage-final.json has the per-line
counts that a merge needs, and the summary has only totals.
Python: coverage combine
[tool.coverage.run]
source = ["shop"]
branch = true
parallel = true
[tool.coverage.paths]
source = ["src/", "*/src/"]
With parallel = true, each coverage run writes its own
.coverage.<host>.<pid>.<random> file. coverage combine merges them into
.coverage and deletes the inputs; --keep leaves them. coverage report
combined them by itself in 7.17.2. For pytest-cov in separate CI jobs, rename
each job’s .coverage to something like .coverage.job1, download them into
one folder and run coverage combine.
| What we tried | What happened |
|---|---|
Two coverage run calls, no parallel | The second overwrote .coverage: 33% |
The second with --append | Combined: 83% |
| Two pytest-cov runs in one folder | The second deleted the first’s .coverage.pricing |
Two checkouts at different paths, no [paths] | Each file listed twice, 42% over 16 statements |
[paths] pattern /tmp/ci/*/src/ on macOS | No match: paths were recorded under /private/tmp |
[paths] with */src/, or relative_files = true | Merged: 83% over 8 statements |
Use --cov-append when several pytest-cov runs share a folder.
What Supercov adds
npx supercov -- npx jest --shard=1/2
npx supercov -- npx jest --shard=2/2
npx supercov merge
npx supercov runs check --min-branches 80
supercov merge with no runs named combined the two shard runs on the same
source, and refuses runs from a different source or configuration rather than
add them up. The merged run keeps which test covered each line, with branches
and MC/DC, and runs check gates it. See Jest coverage
threshold for the floors, and Vitest
coverage for the providers.
More coverage guides
- Jest coverageThreshold: global, per-folder and per-file
- JaCoCo aggregate report for multi-module Maven and Gradle builds
- pytest ignore directory: --ignore, norecursedirs and collect_ignore
- Statement vs branch coverage, with decision, line and path coverage
- JaCoCo report not generated: the causes in Maven and Gradle
- Kover exclude: classes, packages and generated code
- sonar.coverage.exclusions: why SonarQube ignores your JaCoCo excludes
- istanbul ignore next vs c8 ignore next: every hint, measured
- Go test coverage exclude: files, packages and mocks
- Jest coverage exclude: files, folders and lines
- pytest coverage exclude: omit files, folders and lines
- Vitest coverage exclude: files, folders and lines
- JaCoCo exclude in Maven and Gradle: packages, classes and generated code