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.
Important Notes
- 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.