shard
- Type:
{ count: number; index: number } - Default:
undefined - CLI:
--shard <index>/<count>
Shards test files for parallel execution.
count represents the total number of shards, and index represents the index of the current shard (1-based).
This option can only be set at the root level of your configuration, not within individual projects.
This is particularly useful for parallelizing tests in CI/CD environments, allowing you to split the test suite into multiple parts and run them independently across different jobs, thereby reducing overall test time.
- When using the
--shardoption, ensure that thecountandindexvalues are valid. - Test files will be sorted by their path to ensure consistent sharding across different runs.
- Sharding occurs during the test file scanning phase, prior to the build process, to optimize performance.
Merging shard reports
When using sharding in CI, each shard produces its own test report and coverage data independently. To combine the results from all shards into a single report, use the blob reporter along with the rstest merge-reports command.
Step 1: run shards with blob reporter
Configure each shard to output results using the blob reporter:
Each shard writes its results to .rstest-reports/blob-{index}-{count}.json.
Step 2: merge reports
After all shards complete, collect all blob files into a single .rstest-reports/ directory and run:
This will merge all test results, generate a unified summary using your configured reporters, and combine coverage data.
See the CLI documentation for more details on the merge-reports command.