Prompt
What's the best way to run Cypress tests in CI without slowing down the pipeline?
Latest observation
Oct 19, 2026
OpenAI APIWeb search: off
The best way is usually to parallelize Cypress across multiple CI machines and shrink what each run has to do.
Practical approach
-
Split tests across CI workers
- Use Cypress Cloud’s parallelization if available.
- If not, shard specs manually by file or by timing data.
- Goal: each worker runs a subset of specs so total wall time drops.
-
Run only what changed when possible
- Use a targeted test strategy:
- smoke tests on every PR
- full regression on main/nightly
- affected-spec or affected-area runs for small changes
- Don’t make every commit pay for the full suite unless necessary.
- Use a targeted test strategy:
-
Keep the environment warm and fast
- Use cached dependencies (
node_modules, browser binaries, package manager cache). - Build your app once and reuse the artifact across test jobs.
- Prefer stable, dedicated test containers/images.
- Use cached dependencies (
-
Optimize Cypress itself
- Remove unnecessary
cy.wait()calls. - Avoid brittle UI setup in every test; use API/state seeding instead.
- Use
beforeEachcarefully so you aren’t repeating expensive work. - Keep specs independent and not too large.
- Remove unnecessary
-
Run tests headlessly and in parallel only where it helps
- Headless is standard for CI.
- Parallelization helps most when specs have uneven duration or many specs.
-
Use timing data to balance shards
- If you shard by file count alone, one worker may finish much later than others.
- Better: use historical spec duration to balance workload.
-
Separate fast and slow tests
- Smoke/critical path suite on every PR.
- Broader E2E suite on merge to main or scheduled runs.
- This prevents the CI pipeline from being blocked by long-running tests.
A good default CI pattern
- PR pipeline: lint + unit tests + Cypress smoke tests in parallel
- Merge/main pipeline: full Cypress suite sharded across N workers
- Nightly: full suite with retries/reporting
Biggest win in practice
If you only do one thing: parallelize Cypress specs across multiple CI jobs with cached dependencies and a prebuilt app artifact. That usually gives the largest speedup without reducing test coverage.
If you want, I can show a sample setup for GitHub Actions, GitLab CI, or CircleCI.