Pixels drift.
Assertions don't notice. Screenshots do.
Start here
The tools
Playwright toHaveScreenshot
- Kind
- runner
- Pricing
- free
- Baselines
- repository
- Manifest
- converter
pixsame
- Kind
- runner
- Pricing
- free tier, paid plans
- Baselines
- repository or service
- Manifest
- writes it
Percy
- Kind
- hosted review
- Pricing
- free tier, paid plans
- Baselines
- service
- Manifest
- none
BackstopJS
- Kind
- runner
- Pricing
- free
- Baselines
- repository
- Manifest
- converter
| Tool | Kind | Pricing | Baselines | Manifest |
|---|---|---|---|---|
| Playwright toHaveScreenshot | runner | free | repository | converter |
| pixsame | runner | free tier, paid plans | repository or service | writes it |
| Percy | hosted review | free tier, paid plans | service | none |
| BackstopJS | runner | free | repository | converter |
Which diff algorithm fits you?
Every pixel must match
Exact pixels
Counts the one-letter typo (0.07% of the pixels), and also 4.30% for noise nobody can see.
Text renders slightly differently across machines
pixelmatch
Sub-pixel text shift: exact counts 2.60%, pixelmatch 0.66% (1.46% with anti-aliasing detection off).
A color must not drift, even slightly
pixelmatch, low threshold
A three-point color drift: pixelmatch at its default threshold counts 0%, with threshold 0 2.35%; SSIM reads 1.0000.
Images go through JPEG or another lossy step
SSIM
JPEG at quality 60: exact flags 61.90% of the image, pixelmatch 1.80%, SSIM 0.9953.
You want one number a person can read
SSIM
An added cookie notice scores 0.9573, a clean copy 1. But a one-letter typo scores 0.9986: a mean hides small local changes.
Is it still the same picture? Sizes may differ
Perceptual hash
Noise and JPEG: 0 / 64 bits differ. Added element: 18 / 64. Different heights: 26 / 64. A typo: 0 / 64.