Playwright "Error: No tests found" with --shard in CI
Playwright splits the suite across shards with --shard=index/total. If the matrix passes a bad index or a total larger than the test count, a shard can end up with no tests and fail with "No tests found", which fails the whole job.
What this error means
One matrix leg fails with "Error: No tests found" while others pass, or every shard runs the same tests because --shard was not actually applied.
Error: No tests found.
Make sure that arguments are regular expressions matching test files.
shardIndex: 5, shardTotal: 4Common causes
shardIndex out of range for shardTotal
A matrix that generates index values beyond total (or 0-based vs 1-based confusion) asks for a shard that cannot exist.
More shards than tests
With fewer tests than shards, some shards receive nothing and Playwright reports no tests found.
How to fix it
Drive shard index and total from the matrix correctly
Use 1-based indices that never exceed the total, and keep total no larger than your test count.
strategy:
matrix:
shard: [1, 2, 3, 4]
steps:
- run: npx playwright test --shard=${{ matrix.shard }}/4Merge shard reports after the matrix
Use blob reports so an empty shard does not break aggregation and the final report is complete.
npx playwright test --shard=${{ matrix.shard }}/4 --reporter=blobHow to prevent it
- Keep shard total no greater than the number of test files.
- Use 1-based shard indices that match the matrix length.
- Merge blob reports so partial shards aggregate cleanly.