Determinism Across Environments
When to Use
Use this when screenshots pass locally but fail in CI, or when setting up a project to avoid local-vs-CI drift from the start.
The Core Rule
Playwright's own docs: "Browser rendering can vary based on the host OS, version, settings, hardware, power source, headless mode, and other factors. Run tests in the same environment where the baselines were generated."
Decision
| Scenario | Right approach |
|---|---|
| New project | Capture baselines inside Docker from day one |
| macOS dev, Linux CI | Run --update-snapshots inside the Docker container |
| Which platform is "truth"? | linux — CI runs there; *-linux.png are the canonical baselines |
Pattern
Official Docker image
docker pull mcr.microsoft.com/playwright:v1.59.1-noble
Tag taxonomy:
- v1.X.Y-noble — Ubuntu 24.04 LTS (current default)
- v1.X.Y-jammy — Ubuntu 22.04 LTS
Recommended flags: --init, --ipc=host
Pin everything
"devDependencies": { "@playwright/test": "1.59.1" }
Pin the Docker tag to the same version. Never use :latest.
Capture baselines inside Docker
docker run --rm \
--ipc=host \
-v $(pwd):/work -w /work \
--add-host=mysite.ddev.site:host-gateway \
mcr.microsoft.com/playwright:v1.59.1-noble \
npx playwright test --update-snapshots
Common Mistakes
- Wrong:
mcr.microsoft.com/playwright:latest→ Right: pin the tag;:latestchanges with every release - Wrong: Capturing on macOS, comparing in CI → Right: antialiasing differs; always use the same Docker image
- Wrong: Custom Dockerfile without
--with-deps→ Right: missing fonts and system libs produce rendering differences
See Also
- Browser Projects
- Drupal & DDEV
- Reference: Playwright Docker