Playwright error

Error: A snapshot doesn't exist at .../example.spec.ts-snapshots/home-chromium-linux.png, writing actual.

toHaveScreenshot() has no baseline image to compare against for this exact browser and OS combination, so it fails the first run and writes one.

Published

Why this happens

How to fix it

  1. Generate baselines with `npx playwright test --update-snapshots`, review the images, and commit them
  2. Generate Linux baselines inside the same Docker image CI uses (`mcr.microsoft.com/playwright:<version>`) so fonts and rendering match
  3. Don't let CI silently accept the 'writing actual' image as the new baseline. Update snapshots deliberately in a reviewed PR

Example


              # Generate Linux baselines locally in the same image CI uses
docker run --rm -v $(pwd):/work -w /work \
  mcr.microsoft.com/playwright:v1.55.0-noble \
  npx playwright test --update-snapshots