Skip to content

Chapter 7 of 8

CI/CD, Reports, and Parallel Execution

A CI pipeline that runs Playwright reliably needs a few essentials. Install browsers with npx playwright install --with-deps so all required system libraries are present, export CI=1 so the config switches to reuseExistingServer:false, and run npx playwright test as the main step. After the run, upload both playwright-report/ and test-results/ as artifacts so the HTML report, traces, screenshots, and videos are available for debugging without needing to reproduce locally. A common configuration pairs JUnit output (reporter: [['junit', { outputFile: 'results.xml' }]]) with the HTML reporter so CI dashboards and humans both have what they need.

Parallelism in Playwright is on by default and multiplies your throughput, but only if tests are isolated. The recipe is per-test data (unique users, unique IDs), no shared mutable globals, idempotent flows, and per-worker browser contexts. Tag tests so you can run fast smoke suites as a gate (--grep @smoke) and heavy flows behind tags like @slow. For multi-machine execution, --shard=1/3 across three jobs is straightforward, and --workers=1 plus --max-failures=1 are handy when reproducing a single flaky failure locally.

Determinism in CI comes from pinning the Playwright version, installing browsers in the job (not assuming a host install), fixing viewport/locale/timezone/color scheme in the config, and blocking or stubbing external dependencies. For speed, run only the projects you need (often chromium-only), keep the smoke suite tight (login, key page navigation, one create/update flow, one critical report), and prefer API seeding plus storageState over multi-minute UI setup. When a failure happens only in CI, the right reflex is to download the trace.zip and screenshots from artifacts and reproduce locally with the same env vars and --workers=1 rather than blindly retrying.

All chapters
  1. 1Foundations: Installing and Configuring Playwright
  2. 2Selectors, Locators, and Resilient Tests
  3. 3Assertions, Waits, and Avoiding Flakiness
  4. 4Running, Tagging, and Debugging Tests
  5. 5Authentication, State, and Data Isolation
  6. 6Visual Regression and Snapshots
  7. 7CI/CD, Reports, and Parallel Execution
  8. 8Workspace Workflows and AI Agent Collaboration

Drill it

Reading is not remembering. These come from the Anki Playwright Agents deck:

Q

Playwright (Node): minimal setup?

npm i -D @playwright/testnpx playwright installnpx playwright test

Q

Where do Playwright tests live?

Common: ./tests or ./e2e (you choose). Configure testDir in playwright.config.ts so agents know where to add new tests.

Q

Key playwright.config.ts settings?

use.baseURL, webServer (start app), projects (chromium/firefox/webkit), retries/workers, reporter (html + junit), trace/video/screenshot policies.

Q

How do I auto-start my app for tests?

Use playwright.config.ts webServer: { command: "npm run dev", url: "http://127.0.0.1:3000", reuseExistingServer: !process.env.CI }.