Test Sharding "CI_NODE_INDEX" Misconfig - Tests Skipped or Duplicated
Tests are split across parallel CI machines by shard index/total, but the env vars (CI_NODE_INDEX/CI_NODE_TOTAL, or --shard=i/n) are wrong. Shards overlap, skip files, or one node runs the whole suite.
What this error means
A shard runs zero tests ("No tests found" on a high index), runs the entire suite (total defaulted to 1), or coverage/results look duplicated. Off-by-one indexing (0-based vs 1-based) is the usual culprit.
# Playwright shards are 1-based: --shard=index/total
$ npx playwright test --shard=0/4
Error: Shard index must be bigger than 0.
# or a shard quietly runs everything because CI_NODE_TOTAL was unsetCommon causes
Off-by-one or unset shard index/total
Mixing 0-based and 1-based indexing, or leaving CI_NODE_TOTAL/--shard total unset, makes a shard empty or makes every node run the full suite.
Index not unique per parallel job
The matrix did not inject a distinct index per machine, so multiple shards run the same slice and others are never run.
How to fix it
Pass a correct, unique shard per job
# Playwright (1-based)
strategy:
matrix:
shard: [1, 2, 3, 4]
steps:
- run: npx playwright test --shard=${{ matrix.shard }}/4Map CI env vars to the runner's scheme
- Confirm whether your runner is 0-based (
CI_NODE_INDEXoften 0..N-1) or 1-based. - Set both index and total explicitly per parallel job.
- Merge per-shard reports/coverage afterward so nothing is double-counted.
How to prevent it
- Derive shard index and total from the matrix, not hardcoded values.
- Document the indexing scheme (0- vs 1-based) for your runner.
- Add a check that the union of shards covers every test file.