Prompt
visual regression testing in CI
Latest observation
Oct 27, 2026
OpenAI APIWeb search: off
Visual regression testing in CI means automatically comparing your app’s UI screenshots against approved “baseline” images every time code changes, so you can catch unintended visual changes before merge/deploy.
Typical CI workflow
- Build the app
- Run browser tests to open key pages/components
- Take screenshots
- Compare against baselines
- Fail the job if diffs exceed an allowed threshold
- Upload artifacts: diff images, new screenshots, HTML report
Common tools
- Playwright — built-in screenshot testing, good CI support
- Cypress + Percy — popular visual testing workflow
- Loki — strong for component-level visual testing
- Chromatic — especially for Storybook components
- Applitools — AI-based visual regression service
- BackstopJS — classic screenshot diffing
Good CI practices
- Use a fixed viewport and browser version
- Disable animations/time-based content
- Mock dynamic data and external APIs
- Use stable fonts and consistent rendering
- Run in a clean environment (Docker/container)
- Set tolerances for minor anti-aliasing differences
- Review diffs in PRs before updating baselines
Example: Playwright in CI
npx playwright test --update-snapshots
In CI, you usually don’t update snapshots automatically. Instead:
- on main branch: baseline screenshots are stored
- on PRs: screenshots are compared
- if changes are intended: update baselines in a separate reviewed step
Example GitHub Actions outline
name: visual-tests
on: [pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npx playwright install --with-deps
- run: npm run test:visual
- uses: actions/upload-artifact@v4
if: failure()
with:
name: visual-diffs
path: test-results/
What to watch out for
- Flaky tests due to fonts, loading states, or animations
- Differences across OS/browser versions
- Screenshots of highly dynamic content
- Too many snapshots causing slow CI
If you want, I can show:
- a Playwright visual testing setup
- a GitHub Actions config
- or a best-practices checklist for stable visual regression tests.