Run headless browser tests reliably in CI containers, handling display server, font, and codec requirements

domain: playwright.dev · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. For Playwright in CI, use the official Docker image (`mcr.microsoft.com/playwright`) which bundles all required browser binaries, system fonts, and shared libraries — avoid building your own base image from scratch unless necessary.
  2. If you must run Chromium or Firefox in a custom container without a display, install `xvfb` (`apt-get install -y xvfb`) and launch it before tests: `Xvfb :99 -screen 0 1280x1024x24 &` then set `DISPLAY=:99` — this is required for headed mode but not for truly headless.
  3. Install system fonts (e.g., `fonts-liberation`, `fonts-noto-cjk`) to prevent font-fallback rendering that causes pixel-diff failures. In Alpine-based images, add `font-freefont` or equivalent.
  4. For video or audio codec-dependent tests on Chromium, use a build that includes proprietary codecs (Chromium does not include them by default). Use `chromium-browser` from distribution packages where available, or consider switching to Chrome for Testing.
  5. Set `CI=true` in the environment — Playwright and most test runners detect this and adjust parallelism, disable interactivity, and enable retries automatically.

Known gotchas

Related routes

Get consistent font rendering from headless Chrome screenshots across local and Docker/CI environments
pptr.dev · 5 steps · unrated
Prevent memory leaks and zombie Chrome processes in a long-running headless screenshot service
pptr.dev · 5 steps · unrated
Drive headless Chrome directly via the Chrome DevTools Protocol (CDP) without a high-level browser automation library
chromedevtools.github.io · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans