Skip to content

feat(test): add --shard flag to split a test run across machines#35057

Draft
bartlomieju wants to merge 1 commit into
mainfrom
feat/test-shard
Draft

feat(test): add --shard flag to split a test run across machines#35057
bartlomieju wants to merge 1 commit into
mainfrom
feat/test-shard

Conversation

@bartlomieju

Copy link
Copy Markdown
Member

Large test suites are commonly split across CI machines, which Vitest, Jest,
and Playwright all support with a --shard flag. deno test had no
equivalent, so the whole suite had to run on one machine.

This adds deno test --shard=<index>/<count> (1-based index). The discovered
test files are sorted for a stable order, then split into <count>
consecutive, balanced groups, and only the files for <index> are run. Every
file lands in exactly one shard and group sizes differ by at most one. The
selection happens before any --shuffle, so a given shard runs the same files
on every machine regardless of the shuffle seed. Invalid values
(index > count, index or count of 0, missing /) are rejected at
flag-parse time.

Sharding is a pre-filter on the discovered file list, independent of how files
are executed, so it composes cleanly with filtering and any future test-runner
isolation/pooling changes.

This intentionally does not include cross-shard result merging (a combined
summary across shards); each shard reports its own subset and fails its own CI
job, and a merge step pairs naturally with the json reporter as a follow-up.

`deno test --shard=<index>/<count>` runs only the test files belonging to
the given 1-based shard, so a suite can be split across machines (as in
Vitest, Jest, and Playwright). The discovered files are sorted for a stable
order and split into <count> consecutive, balanced groups; the selection
happens before any --shuffle so it is deterministic across machines.
@bartlomieju bartlomieju added this to the 2.9.0 milestone Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant