Interview Prep/CI/CD/Testing and Quality Gates

How do you shard and parallelise a long test suite?

AdvancedConceptTesting and Quality Gates
Answer

Split tests across N runners using timing data so shards finish around the same time, rather than splitting by file count. Playwright has --shard=1/4, Jest has --shard, pytest uses pytest-xdist (-n auto) within a machine and pytest-split across machines, GitLab uses parallel: with CI_NODE_INDEX. Ensure tests are isolated (no shared database rows), merge coverage and JUnit reports from all shards afterwards.

strategy:
  matrix: { shard: [1, 2, 3, 4] }
steps:
  - run: npx playwright test --shard=${{ matrix.shard }}/4
All CI/CD questions Roadmap: CI/CD fundamentals

More on Testing and Quality Gates