Back to cheat sheet hub

Playwright CI/CD Cheat Sheet

A practical guide for taking a Playwright framework from local execution to repeatable CI pipelines and containerized runs.

Playwright Module 8 Framework + CI Docker + GitHub Actions

Framework Structure

Keep the test architecture obvious and scalable.

tests/
pages/
fixtures/
utils/
test-data/
playwright.config.ts

Data and Config

Centralize environment-specific values and test data instead of hardcoding.

Use:
- env files
- JSON / CSV fixtures
- typed config helpers

Utilities and Logging

Shared helpers should reduce noise, not hide important behavior.

Good utility areas:
- data builders
- auth helpers
- API helpers
- log formatting

Reporting

Reports need to help triage failures quickly in CI.

Common outputs:
- HTML report
- JSON report
- trace files
- screenshots
- videos

GitHub Actions Basics

Automate install, test execution, and artifact upload on pushes and PRs.

on:
  push:
  pull_request:

Artifacts

Upload the evidence needed to debug failures without rerunning blindly.

- playwright-report
- test-results
- traces
- screenshots

Docker Basics

Containers help make runs consistent across CI environments.

Use the official Playwright image:
mcr.microsoft.com/playwright

Parallel CI

Use sharding or matrix runs only when the suite is already isolated and stable.

npx playwright test --shard=1/3

Documentation Matters

Frameworks age better when the setup and run commands are documented clearly.

Document:
- local run steps
- CI triggers
- env vars
- reporting paths
- common debug commands