Skip to content

feat: support merging reports and coverage when using test sharding#1054

Merged
9aoy merged 3 commits intomainfrom
merge-reports
Mar 16, 2026
Merged

feat: support merging reports and coverage when using test sharding#1054
9aoy merged 3 commits intomainfrom
merge-reports

Conversation

@9aoy
Copy link
Copy Markdown
Collaborator

@9aoy 9aoy commented Mar 13, 2026

Summary

Users can now shard tests across CI machines and merge all results into a single report with rstest merge-reports, including combined coverage.

Background

When tests are split across multiple CI machines using --shard, each shard produces isolated test reports and coverage data with no way to combine them into a unified result.

Implementation

  • Added a blob built-in reporter that serializes test results, durations, snapshots, console logs, and errors to JSON files (.rstest-reports/blob-{index}-{count}.json)
  • Added rstest merge-reports [path] CLI command that loads blob files, replays results through configured reporters, merges coverage data via istanbul, and optionally cleans up with --cleanup
  • Blob reporter is automatically excluded during merge to avoid re-producing blob output
  • Per-shard duration breakdown is displayed during merge

Shard Workflow

  1. Run each shard with the blob reporter to generate blob report files:
# On CI machine 1
npx rstest run --shard 1/3 --reporter=blob

# On CI machine 2
npx rstest run --shard 2/3 --reporter=blob

# On CI machine 3
npx rstest run --shard 3/3 --reporter=blob
  1. Collect all .rstest-reports/ directories into a single location, then merge:
npx rstest merge-reports

By default, blob reports are read from .rstest-reports/ in the project root. You can specify a custom path:

npx rstest merge-reports ./custom-reports-dir

The merge command will:

  • Combine test results from all shards
  • Run configured reporters (e.g., default, junit) with the merged data
  • Merge and generate coverage reports (if coverage is enabled)

Use --cleanup to remove the blob reports directory after merging:

npx rstest merge-reports --cleanup

Related Links

close #1044

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Mar 13, 2026

Deploying rstest with  Cloudflare Pages  Cloudflare Pages

Latest commit: d77a541
Status: ✅  Deploy successful!
Preview URL: https://5b6f792c.rstest.pages.dev
Branch Preview URL: https://merge-reports.rstest.pages.dev

View logs

@9aoy 9aoy merged commit a15beab into main Mar 16, 2026
10 checks passed
@9aoy 9aoy deleted the merge-reports branch March 16, 2026 03:10
@9aoy 9aoy mentioned this pull request Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Support merging reports and coverage when using test sharding

1 participant