Playwright · Reliable end-to-end tests

How does test sharding work?

MediumshardingciparallelismUpdated Oct 2026
Quiz this track

Short answer

--shard=1/4 runs one quarter of the suite, balanced by test file. Combine shards in a CI matrix, then merge blob reports into one HTML report.

Sharding splits the suite across separate CI jobs rather than separate workers on one machine. Each shard runs a deterministic subset, so four jobs can finish in roughly a quarter of the time if the test files are balanced.

bash
npx playwright test --shard=1/3
npx playwright test --shard=2/3
npx playwright test --shard=3/3
Each command runs a different third of the suite; the split is stable across runs.
bash
npx playwright test --reporter=blob
npx playwright merge-reports --reporter=html blob-report
Blob reports from each shard can be merged into a single HTML report.

Practical points

  • Shards are balanced by test file, not by individual test
  • One large slow file can dominate a shard and leave the others idle
  • Use a CI matrix to launch each shard as its own job
  • Upload each shard's blob report, then merge them in a final job
  • Sharding multiplies shared environment cost but reduces wall-clock time
  • Sharding is not a substitute for parallel workers inside a shard

If shard times are uneven, split the heavy file or move long setup work into a worker-scoped fixture. Adding more shards than there are reasonably sized files produces diminishing returns and more overhead.

Each shard needs the same application version, seeded data and environment. If one shard points at a different backend, the merged report will mix results from different systems.

Follow-ups you should expect

Interviewers use these to check whether the first answer was understanding or memorisation.

  1. 1How are tests distributed across shards?
  2. 2Why can shard times be uneven?
  3. 3How do you merge reports from several shards?
  4. 4When does sharding stop helping?

Say it in the interview

Sharding runs a deterministic subset of the suite per CI job, so several machines can work in parallel. The split is by test file, which means one heavy file can make a shard slow. I launch the shards in a CI matrix, use blob reports and merge them into one HTML report. I keep each shard on the same app version and data setup so the merged results are comparable.

Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.

Related questions

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Playwright mock interview and get scored feedback on depth, clarity and confidence.