Prompt
I'm unhappy with flaky visual regression tests in CI
Latest observation
Oct 27, 2026
OpenAI APIWeb search: off
Flaky visual regression tests in CI are usually a symptom, not the disease. The usual causes are:
-
Non-deterministic rendering
- fonts differ between local and CI
- anti-aliasing / subpixel differences
- GPU / headless browser differences
- animations, transitions, loading states
-
Environment drift
- different OS/browser versions
- missing system fonts
- different viewport/device scale factor
- locale/timezone differences
-
Test timing issues
- screenshots taken before the UI is fully settled
- async data still loading
- skeletons/spinners briefly visible
-
Too much visual surface
- full-page screenshots capture irrelevant noise
- tiny, unimportant shifts fail the test
What usually helps most, in order:
-
Stabilize the environment
- pin browser version
- run on the same OS image in CI
- install required fonts
- fix viewport, DPR, locale, timezone
-
Make the UI deterministic
- disable animations/transitions in test mode
- mock timers, dates, random values, and network data
- wait for “ready” signals before screenshotting
-
Reduce screenshot scope
- capture components or smaller page regions instead of whole pages
- hide dynamic areas like ads, avatars, timestamps, cursors
-
Tune diff thresholds carefully
- allow minor pixel tolerance
- use a perceptual diff tool if appropriate
- don’t just raise thresholds blindly
-
Quarantine and classify failures
- distinguish real regressions from noise
- auto-retry only to confirm flakiness, not to mask it
- track failure patterns to find the root cause
If you want, I can help you build a concrete plan for your stack—e.g. Playwright, Cypress, Percy, Chromatic, Storybook, or a custom screenshot setup.