A minimalist blog built with Astro and hosted on Cloudflare Pages
Visual snapshot tests catch unintended layout changes from Astro or dependency updates. They compare full-page screenshots of key routes against committed baselines in tests/visual.spec.ts-snapshots/.
Baselines are produced and compared on Linux in CI. Screenshots generated on macOS may differ slightly.
npm ci
npx playwright install chromiumPlaywright browsers are downloaded separately from npm packages.
npm run test:visualThis builds the site, serves the production build with astro preview, and fails if any screenshot differs from the committed baseline.
- Open the failed GitHub Actions run for the Visual snapshot tests job.
- Download the
visual-test-resultsartifact. It contains actual, expected, and diff images for failed comparisons. - Decide whether the change is:
- Unintended regression — fix the CSS or layout and push again.
- Intentional layout change — update the snapshots (steps below).
Prefer refreshing baselines from CI so they match Linux rendering:
- Download the
visual-test-resultsartifact from the failed job. - Copy each
*-actual.pngfromtest-results/over the matching file intests/visual.spec.ts-snapshots/. - Commit the updated PNGs and push.
For a local refresh (may still fail CI if fonts/rendering differ):
npm run test:visual:updateReview the changed PNGs, commit them with your layout change, and push. If CI still fails, replace baselines from the CI artifact as above.
Renovate or Astro dependency bumps may fail this check. Updating snapshots is how you approve a new visual baseline.
After this workflow is on master, mark Visual snapshot tests as a required status check in GitHub branch protection so pull requests cannot merge when screenshots differ.