Skip to content

About

Senior-level Playwright + TypeScript template for UI and API test automation with CI reporting, Allure, CTRF, and clean test architecture.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

234 Commits

Folders and files

Repository files navigation

Awesome Playwright Template

CI Allure Report Playwright TypeScript Node.js Test scope

Playwright + TypeScript template that showcases a senior-level automation approach for both UI and API testing.

Dynamic Dependency & Security Matrix

Click to expand (7 outdated, 14 vulnerabilities: 3 high, 11 medium)
Dependency Type Requested Version Security Status Latest npm Version
@dotenvx/dotenvx devDependencies ^2.38.2 🟒 No findings in supplied report 2.38.2
@eslint/js devDependencies ^10.0.1 🟒 No findings in supplied report 10.0.1
@playwright/test devDependencies 1.64.1 🟒 No findings in supplied report 1.65.1 ⚠️
@types/node devDependencies ^26.6.6 🟒 No findings in supplied report 26.6.11 ⚠️
allure devDependencies ^3.33.0 🟑 3 medium 3.33.0
allure-playwright devDependencies ^3.15.0 🟒 No findings in supplied report 3.15.0
eslint devDependencies ^10.15.0 πŸ”΄ 1 high, 🟑 2 medium 10.16.0 ⚠️
eslint-plugin-playwright devDependencies ^2.12.2 πŸ”΄ 1 high, 🟑 2 medium 2.12.2
lint-staged devDependencies ^17.6.1 🟒 No findings in supplied report 17.6.2 ⚠️
pino dependencies ^10.4.0 🟒 No findings in supplied report 10.4.0
pino-pretty dependencies ^13.2.0 🟒 No findings in supplied report 13.2.0
playwright-ctrf-json-reporter devDependencies ^0.2.0 🟑 2 medium 0.3.0 ⚠️
prettier devDependencies ^3.10.1 🟒 No findings in supplied report 3.10.1
simple-git-hooks devDependencies ^2.14.0 🟒 No findings in supplied report 2.14.0
typescript devDependencies ^6.0.3 🟒 No findings in supplied report 7.0.2 ⚠️
typescript-eslint devDependencies 8.73.0 πŸ”΄ 1 high, 🟑 2 medium 8.74.0 ⚠️
zod devDependencies ^4.6.7 🟒 No findings in supplied report 4.6.7

Table generated by dependency-security-matrix-action.

What this repo demonstrates

  • UI automation against https://www.saucedemo.com
  • API automation against Supabase PostgREST
  • Deep module structure: CRUD separated from assertions, thin page objects, resource lifecycle fixtures
  • Separate Playwright projects for UI and API execution
  • CI-ready reporting, retries, traces, linting, type checking, and local Git hooks

Test catalog

The automated test cases are tracked in the Awesome PW Template: Test Catalog.

Documentation

Project structure

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                               TESTS LAYER (tests/)                                β”‚
β”‚                                                                                   β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚   β”‚     api/*.spec.ts     β”‚      β”‚     ui/*.spec.ts      β”‚    β”‚ auth.setup.ts β”‚   β”‚
β”‚   β”‚     (5 API specs)     β”‚      β”‚     (7 UI specs)      β”‚    β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜            β”‚           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                β”‚                        β”‚           β”‚                  β”‚
                β”‚                        β”‚           └───────┐          β”‚
                β–Ό                        β–Ό                   β”‚          β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚          β”‚
β”‚        INFRASTRUCTURE         β”‚  β”‚ CORE BUSINESS LOGIC  β”‚  β”‚          β”‚
β”‚       (infrastructure/)       β”‚  β”‚     (business/)      β”‚  β”‚          β”‚
β”‚                               β”‚  β”‚                      β”‚  β”‚          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚          β”‚
β”‚  β”‚        Fixtures         β”œβ”€β”€β”Όβ”€β”€β”Όβ”€β–Άβ”‚   API Domain   β”‚  β”‚  β”‚          β”‚
β”‚  β”‚  api.fixture.ts,        β”‚  β”‚  β”‚  β”‚    objects,    β”‚  β”‚  β”‚          β”‚
β”‚  β”‚  ui.fixture.ts          β”‚  β”‚  β”‚  β”‚   assertions,  β”‚  β”‚  β”‚          β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚  β”‚   factories    β”‚  β”‚  β”‚          β”‚
β”‚               β”‚               β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚          β”‚
β”‚               β”‚               β”‚  β”‚          β”‚           β”‚  β”‚          β”‚
β”‚               β–Ό               β”‚  β”‚          β”‚           β”‚  β”‚          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚          β”‚           β”‚  β”‚          β”‚
β”‚  β”‚    restful.client.ts    β”‚β—€β”€β”Όβ”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β”‚  β”‚          β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚          β”‚
β”‚               β”‚               β”‚  β”‚  β”‚    Journeys    β”‚β—€β”€β”Όβ”€β”€β”˜          β”‚
β”‚               β–Ό               β”‚  β”‚  β”‚  login, cart,  β”‚  β”‚             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚  β”‚ checkout, etc. β”‚  β”‚             β”‚
β”‚  β”‚      config/env.ts      β”‚  β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚             β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜             β”‚                         β”‚
                                              β–Ό                         β–Ό
                                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                   β”‚         PAGE OBJECTS (pages/)          β”‚
                                   β”‚                                        β”‚
                                   β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
                                   β”‚  β”‚       Flow       β”‚  β”‚login.page  β”‚  β”‚
                                   β”‚  β”‚ inventory, cart, β”‚  β”‚    .ts     β”‚  β”‚
                                   β”‚  β”‚ checkout, detail β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
                                   β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                  β”‚
                                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Design principles

  • Deep modules over shallow wrappers β€” API client interface is 6 methods (CRUD only); assertions are composed separately
  • Thin POMs via composition, not inheritance β€” pages stay standalone with a lightweight base
  • Fixture-managed resource lifecycles β€” collection scopes per test, auto-generated via fixture
  • Deterministic data factories β€” every test creates its own data; no shared state
  • Extracted auth β€” login uses a page object and TTL-cached storage state

Getting started

The supported flow is inside the devcontainer, which mirrors the Playwright Docker image used in CI (browsers and toolchain included, no npx playwright install needed):

  1. Install the VS Code Dev Containers extension locally and start Docker.
  2. Make sure .env.local exists. UI tests still load playwright.config.ts, so API_BASE_URL must be present even when you only run SauceDemo UI tests.
  3. Open the command palette and run Dev Containers: Reopen in Container. Setup runs npm ci automatically and the container resolves to <folder>-dev.
  4. Inside the container, verify and test:
npm run check
npm test            # Full suite (UI + API)

Without devcontainer (fallback, running only)

Prefer the devcontainer above; use the host only to run tests, and still rebuild lockfiles inside the devcontainer. Requires Node 22:

npm ci
npx playwright install chromium firefox webkit
npm run check

Dev container

This repo includes a VS Code devcontainer that mirrors the Playwright Docker image used in CI:

  • Base image: mcr.microsoft.com/playwright:v1.63.0-noble
  • Node.js and npm: supplied by the official image
  • Rebuild lockfiles from inside this devcontainer: npm install regenerates package-lock.json, and rebuilding the container refreshes .devcontainer/devcontainer-lock.json
  • Run tests from inside this devcontainer (npm test, npm run test:ui, npm run test:api, npm run check) so Node, browsers, and system dependencies match CI
  • Shell: zsh with Oh My Zsh, configured as the default terminal
  • Install step: npm ci
  • Version guard: npm run verify:playwright checks devcontainer and CI Playwright Docker images against package-lock.json
  • Browser stability flag: --ipc=host
  • Playwright UI Mode port: 9323

Follow Getting started for the container flow. Once inside, start Playwright UI Mode:

npm run test:ui:mode

The UI Mode server binds to 0.0.0.0:9323 so VS Code can forward it from the container to your browser.

To run API tests, complete the Supabase API setup first, then:

npm run test:api    # API only
npm test            # Full suite (UI + API)

Supabase API setup

The API tests run against a Supabase PostgREST endpoint. Here's how to set it up:

1. Create a Supabase project

  1. Go to supabase.com and sign up.
  2. Create a new project β€” choose any name (e.g. awesome-pw-tests), generate a database password, pick the closest region, and select the Free plan.
  3. Wait 1–2 minutes for the project to provision.

2. Create the table and RLS policy

Open the SQL Editor in your Supabase dashboard and run:

create table objects (
  id uuid default gen_random_uuid() primary key,
  "collectionName" text not null,
  name text not null,
  data jsonb default '{}'::jsonb,
  "createdAt" timestamptz default now(),
  "updatedAt" timestamptz default now()
);

alter table objects enable row level security;

create policy "anon_crud" on objects
  for all
  using (true)
  with check (true);

3. Configure environment variables

Go to Settings β†’ Data API in your Supabase dashboard and copy:

  • Project URL (e.g. https://abc123.supabase.co)
  • anon public key

Add them to your env files:

# .env.local (local development)
API_BASE_URL=https://<your-project>.supabase.co
API_KEY=<your-supabase-anon-key>
# .env.production (CI, encrypted)
API_BASE_URL=https://<your-project>.supabase.co
API_KEY=<your-supabase-anon-key>

For CI, encrypt .env.production using dotenvx:

npx dotenvx encrypt

4. Run the API tests

npm run test:api

Scripts

Local development

  • npm test β€” Run the full suite (UI + API)
  • npm run test:ui β€” Run SauceDemo across Chromium, Firefox, WebKit
  • npm run test:api β€” Run API tests against the configured Supabase project
  • npm run test:headed β€” Run SauceDemo Chromium in headed mode
  • npm run test:debug β€” Debug SauceDemo Chromium
  • npm run test:ui:mode β€” Open Playwright UI Mode on forwarded port 9323
  • npm run report β€” Open the HTML test report
  • npm run check β€” Verify Playwright Docker image versions, lint, and typecheck

Git hooks

Local hooks are managed by simple-git-hooks and installed by npm install through the prepare script:

  • pre-commit β€” runs lint-staged
  • pre-push β€” runs npm run typecheck

lint-staged runs ESLint autofix and Prettier on staged TypeScript files, and Prettier on staged JS, JSON, Markdown, and YAML files.

CI

  • npm run test:ci β€” Full suite via encrypted .env.production
  • npm run test:ui:ci β€” UI tests (Chromium, Firefox, WebKit) via encrypted .env.production
  • npm run test:api:ci β€” API tests via encrypted .env.production

CI pipeline

The .github/workflows/playwright.yml workflow runs on every push to main, pull request, and Monday/Thursday at 13:00 in the Asia/Jerusalem timezone.

Dependency and security automation

  • .github/dependabot.yml keeps npm packages and GitHub Actions versions fresh with weekly Monday update checks.
  • Dependabot groups reporting packages, TypeScript/linting tooling, and GitHub Actions updates into focused PRs. Playwright version updates are intentionally managed manually because the npm package, devcontainer image, and CI image must be upgraded together.
  • .github/workflows/snyk-security.yml runs on dependency changes, manual dispatch, non-Dependabot pull requests, and a weekly Monday schedule.
  • The Snyk scan uses one optional repository Actions secret: SNYK_TOKEN. Dependabot PRs skip this workflow because GitHub does not expose Actions secrets to Dependabot-triggered runs.
  • The workflow uses thisromanHQ/dependency-security-matrix-action@v1 to update the dependency matrix on non-PR runs. When SNYK_TOKEN is unavailable or invalid, the matrix still updates with dependency versions and latest npm versions, but without scanner-backed security status.
  • When SNYK_TOKEN is available, the workflow also uploads SARIF results to GitHub Security.

Jobs

  • lint β€” always runs npm run check (linter + typecheck)
  • api-tests β€” depends on lint; always runs Playwright API project against Supabase PostgREST
  • ui-tests β€” depends on lint; always runs the chromium / firefox / webkit matrix against saucedemo.com
  • ctrf-report β€” depends on api-tests and ui-tests; always aggregates CTRF JSON into a PR comment via ctrf-io/github-test-reporter
  • report-site β€” depends on api-tests and ui-tests; merges Playwright HTML and publishes Allure on pushes to main
  • deploy-pages β€” deploys the combined responsive report site to GitHub Pages

Test reporting

CTRF β€” PR summary

  • Each test job sets CTRF_REPORT_FILE: ctrf-<project|browser>.json
  • playwright.config.ts conditionally registers playwright-ctrf-json-reporter when the env var is set
  • The reporter writes to ctrf/<filename> (default subdirectory)
  • Uploaded as artifact ctrf-*
  • ctrf-report job downloads all ctrf-* artifacts, merges, and runs ctrf-io/github-test-reporter with summary-report: true, insights-report: true, suite-folded-report: true + group-by: suite + upload-artifact: true (processed CTRF artifact enables multi-run insights across previous workflow runs)

Reports β€” GitHub Pages dashboard

  • Allure and merged Playwright HTML are deployed together via actions/deploy-pages@v5
  • Only runs on push to main (not on PRs)
  • Accessible at https://roman-pinchuk.github.io/awesome-pw-template/
  • The landing page offers a single theme button cycling Auto, Light, and Dark (like the Allure report control) and responsive desktop, tablet, and mobile layouts.

Allure 3 history

  • The official allure CLI generates the report from allure-results/.
  • allurerc.mjs stores cross-run history in allure-history/history.jsonl and limits it to 20 runs.
  • scripts/publish-allure-report.mjs keeps the matching 20 report directories.
  • scripts/build-report-site.mjs enforces both a 20-report limit and a 500 MiB published-site limit, pruning oldest Allure reports first.
  • Raw Playwright, CTRF, and Allure artifacts are retained for one day; the Pages deployment artifact is also retained for one day.
  • The complete allure-history/ directory is restored and saved with a branch-scoped GitHub Actions cache before deployment.
  • History starts fresh after the migration because Allure 3 uses JSONL rather than Allure 2's history/ files. GitHub cache eviction can remove history; use Allure Report Storage when durable history is required.

Action versions

  • actions/checkout β€” @v7, latest as of 2026-07
  • actions/setup-node β€” @v7, latest as of 2026-07
  • actions/upload-artifact β€” @v7, latest as of 2026-07
  • actions/download-artifact β€” @v8, latest as of 2026-07
  • actions/cache β€” @v6, latest as of 2026-07
  • actions/cache/restore β€” @v6, latest as of 2026-07
  • actions/cache/save β€” @v6, latest as of 2026-07
  • actions/upload-pages-artifact β€” @v5, latest as of 2026-07
  • actions/deploy-pages β€” @v5, latest as of 2026-07
  • ctrf-io/github-test-reporter β€” @v1.3.0, latest as of 2026-07
  • allure β€” 3.16.0, official Allure Report CLI

Environment loading

  • Local β€” infrastructure/config/env.ts loads .env.local via @dotenvx/dotenvx when CI is not set. API_BASE_URL and API_KEY are validated at startup.
  • CI β€” the test:*:ci scripts use dotenvx run -f .env.production to decrypt and inject the encrypted .env.production file.
  • playwright.config.ts and infrastructure/config/env.ts validate the injected environment before tests run.
  • API requests read API_BASE_URL (Supabase project URL) and API_KEY (anon key) from the active env file.

About

Senior-level Playwright + TypeScript template for UI and API test automation with CI reporting, Allure, CTRF, and clean test architecture.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Used by

Contributors

Languages