Prompt
I'm unhappy with visual tests taking too long in CI, how do teams speed this up?
Latest observation
Oct 27, 2026
OpenAI APIWeb search: off
Teams usually speed up visual tests in CI by reducing how much they compare, how often they compare, and where they run the expensive parts.
Common approaches:
1. Run fewer visual tests
- Smoke set vs full suite: run a small “critical pages/components” set on every PR, and the full matrix nightly or on merge to main.
- Risk-based selection: only test pages likely affected by the change.
- Component-level tests instead of full-page E2E screenshots where possible.
2. Parallelize aggressively
- Split tests across multiple CI workers/shards.
- Run browser/platform combinations in parallel.
- If using a cloud visual testing service, let it distribute the workload.
3. Use baselines smartly
- Avoid re-processing or re-uploading unchanged baselines.
- Cache reference images/artifacts between runs.
- Only update baselines when explicitly approved.
4. Reduce the size/cost of captures
- Capture fewer viewport sizes, browsers, or themes per PR.
- Prefer deterministic, smaller test pages and fixtures.
- Disable animations, video, ads, maps, and other dynamic content.
5. Make tests more deterministic
- Stabilize fonts, dates/times, locale, network responses, and random data.
- Fewer flaky diffs means fewer reruns, which often saves more time than raw speed improvements.
6. Compare at the right level
- Use DOM/component snapshot tests for fast feedback, and reserve pixel-perfect visual diffs for higher-value flows.
- Some teams use cheap prechecks first, then do pixel diff only when the precheck passes or when a change touches UI code.
7. Optimize the CI environment
- Use larger/faster runners if the bottleneck is CPU or rendering.
- Prebuild dependencies and cache browser binaries, npm/pip packages, fonts, and test assets.
- Run on ephemeral environments with warm caches if possible.
8. Reduce review overhead
- Auto-approve obvious unchanged screenshots.
- Group related diffs.
- Use AI/heuristics or strict thresholds to cut noise, so humans spend less time triaging.
9. Move some work out of CI
- Run visual regression locally before pushing.
- Use pre-commit hooks or developer tooling for quick checks.
- Reserve CI for authoritative verification.
A typical fast setup
Many teams use:
- PRs: only critical components/pages, 1–2 browsers, one viewport, no animations, parallelized
- Main/nightly: full cross-browser and multi-viewport suite
- On-demand: full rebaseline or expanded checks for UI-heavy changes
If you want, I can suggest a concrete strategy based on your stack (Playwright/Cypress/Selenium, Storybook, Percy/Chromatic/Screener, etc.) and what’s currently slow.