How do you parallelise Cypress tests?
One cypress run drives one browser and runs specs one after another, so parallelism in Cypress means several machines, not several processes on one. The unit of distribution is a spec file. The official way is Cypress Cloud with --record and --parallel, which balances specs dynamically. A free alternative is a CI job matrix with the cypress-split plugin. Parallel jobs need isolated data.
Cypress · Parallelism
A run takes 40 minutes. Can you just start Cypress in several processes on one machine?
Two hundred specs at ten to twelve seconds each add up to about forty minutes of sequential running, and PR feedback becomes too slow. In Playwright the answer "add workers" works on one machine. In Cypress it does not: one process drives one browser and runs specs one after another. This lesson explains why and shows two ways to split the work between machines.
How it works and why. Cypress runs the test in the browser, so one cypress run serves one browser and one spec at a time. Parallelism means several independent runs on different machines (or containers), each with its own browser. The unit of distribution is a spec file: inside a file tests run sequentially. So speed depends on two things: how many machines and how even the shares turn out. The two approaches differ in who decides which spec goes to which machine.
Who distributes the specs
Dynamic distribution
Each machine asks the service for the next spec, and the service uses duration history. Uneven specs even out by themselves. Recording and a key are needed; beyond the free limit it is paid.
Static distribution
Each job computes its share of specs in advance from SPLIT and SPLIT_INDEX. No service or key, but one heavy spec keeps its job longer than the rest.
Example: 40 minutes on 4 machines. The free route: a matrix of four jobs and the cypress-split plugin. The plugin is wired in the config:
// cypress.config.ts
import { defineConfig } from 'cypress';
import cypressSplit from 'cypress-split';
export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
cypressSplit(on, config); // leaves this job only its share of specs
return config;
},
},
});
And the matrix gives each job the total and its own index:
jobs:
cypress:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
containers: [1, 2, 3, 4]
steps:
- uses: actions/checkout@v7
- uses: cypress-io/github-action@v7
with:
start: npm start
wait-on: 'http://localhost:3000'
env:
SPLIT: ${{ strategy.job-total }}
SPLIT_INDEX: ${{ strategy.job-index }}
- uses: actions/upload-artifact@v7
if: failure()
with:
name: screenshots-${{ strategy.job-index }}
path: cypress/screenshots
if-no-files-found: ignore
strategy.job-index starts at zero, and so does SPLIT_INDEX, so the matrix values fit without conversion. fail-fast: false stops the first red job from cancelling the rest: otherwise you would not see part of the results. The artifact name contains the index because, since upload-artifact v4, several jobs cannot write to one artifact with the same name. The expected gain is roughly a quarter of the test time plus each job's overhead (checkout, cache, server start), so four machines do not give exactly ×4.
The official route through Cypress Cloud looks like this:
- uses: cypress-io/github-action@v7
with:
record: true
parallel: true
group: e2e-chrome
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
All machines with the same group and build id (ci-build-id) count as one run. For most CI providers (GitLab and Jenkins among them) Cypress detects the id automatically; the --ci-build-id flag is needed only when detection fails. Cypress rejects the --parallel flag without --record: the balancing is done by the service, so without recording nobody distributes the specs.
Limits and alternatives. The free Cypress Cloud plan includes parallelisation and load balancing within a monthly limit of test results (500 at the time of writing), and beyond it is paid: check the current terms on the pricing page. Static splitting is cheap but sensitive to skew: one 15-minute spec among small ones keeps its job longest, and extra machines no longer help. Parallel jobs also share the environment: if they write to a shared database or one account, tests start to interfere, so data must be isolated. In Playwright the same work is done by workers on one machine (half the cores by default) and --shard=1/4 across machines with merge-reports for merging the reports, and the default unit is also a file, with fullyParallel: true a single test.
Typical mistakes.
- Expecting parallelism on one machine: Cypress runs specs sequentially, several machines are needed.
- Keeping a few huge specs: they become the bottleneck. Split them by scenario.
- Shared data between parallel jobs (one user, one database): tests break each other and flakiness appears.
- Forgetting
fail-fast: falseor unique artifact names: part of the diagnostics disappears.
Check yourself
A matrix of four jobs with cypress-split, but one spec takes 15 minutes and the rest a second each. Why did the run barely speed up and what do you do?
Answer
A spec is indivisible: one job runs it, and the whole run lasts at least as long. Split the big spec into several files by scenario, then they can be spread across machines.
Why does cypress run --parallel without --record not work?
Answer
Distribution of specs between machines is done by Cypress Cloud while the run is recorded. Without recording there is no service, so Cypress rejects the flag.