Skip to content
Latchkey

Playwright "snapshot doesn't exist, writing actual" in CI

Playwright found no committed reference for this screenshot. On the first encounter it writes the current render as the new baseline and fails the test on purpose, so a brand-new baseline never silently passes in CI.

What this error means

A screenshot assertion fails with "Error: A snapshot doesn't exist at ...-snapshots/name.png, writing actual." The test passes locally (where the file just got written) but keeps failing in CI because the baseline was never committed.

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

Common causes

The baseline PNG was never committed to the repo

The reference file lives in a -snapshots/ folder next to the test. If it is gitignored or was never added, CI has nothing to compare against and writes a fresh actual instead.

The platform-specific baseline is missing

Playwright names baselines per browser and OS. A macOS-only baseline is committed, but the Linux CI runner needs -linux.png, which does not exist yet.

How to fix it

Generate and commit the baseline for the CI platform

  1. Run the update in the same OS image CI uses so the correct -linux baseline is produced.
  2. Confirm the new PNG is not covered by .gitignore.
  3. Commit the baseline files under the -snapshots/ directory.
Terminal
docker run --rm -v $(pwd):/work -w /work \
  mcr.microsoft.com/playwright:v1.44.0-jammy \
  npx playwright test --update-snapshots
git add '**/*-snapshots/**'

Stop gitignoring snapshot folders

Baselines are test fixtures and must be versioned. Make sure your ignore rules do not exclude the snapshot directories or .png files under them.

.gitignore
# .gitignore - do NOT ignore committed baselines
test-results/
!**/*-snapshots/

How to prevent it

  • Commit baseline PNGs for every platform your CI runs on.
  • Keep -snapshots/ directories out of .gitignore.
  • Generate first baselines inside the CI container, not only locally.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →