Prompt
What should I use for visual diffing with Playwright?
Latest observation
Nov 9, 2026
OpenAI APIWeb search: off
For visual diffing with Playwright, the best default choice is:
Use Playwright’s built-in screenshot assertions
Playwright already supports visual regression testing out of the box with:
expect(page).toHaveScreenshot()expect(locator).toHaveScreenshot()
This is usually the simplest and most reliable option if you’re already using Playwright for E2E tests.
Why this is a good choice
- Built into Playwright: no extra framework needed
- Cross-browser support: works with Chromium, Firefox, and WebKit
- Easy baselines: stores expected screenshots in your repo
- Auto-waiting: integrates nicely with Playwright’s testing model
When to use it
Use Playwright’s screenshot assertions if you want to catch:
- layout regressions
- spacing/alignment changes
- missing or broken UI elements
- font/rendering differences
- responsive UI changes
Typical setup
import { test, expect } from '@playwright/test';
test('homepage looks correct', async ({ page }) => {
await page.goto('https://example.com');
await expect(page).toHaveScreenshot('homepage.png');
});
Things to configure for stable diffs
Visual tests can be flaky unless you control:
- animations: disable them
- dynamic content: mock or freeze timestamps, ads, randomized data
- fonts: make sure the same fonts are available in CI
- viewport: set fixed sizes
- masking: hide dynamic regions if needed
Example:
await expect(page).toHaveScreenshot('homepage.png', {
animations: 'disabled',
mask: [page.locator('.timestamp')],
});
If you need a dedicated visual testing platform
If you want review workflows, baseline management, and collaboration features, consider:
- Percy
- Applitools
- Chromatic (especially for Storybook)
- Argos
- Visual Regression Tracker
These are useful if:
- you have many screenshots
- non-developers review UI changes
- you want approval workflows
- you need better dashboards and diff reporting
Recommendation
Choose based on your needs:
- Small/medium project → Playwright built-in screenshot assertions
- Large team / lots of UI review → Percy or Applitools
- Storybook-heavy workflow → Chromatic
If you want, I can also give you:
- a recommended Playwright visual testing setup, or
- a comparison table of Playwright vs Percy vs Applitools vs Chromatic.