Active Sep 2026

Playwright E2E Guides Template (Tested Journeys as User Guides)

Role: Solo, end-to-end: recorder and manifest design, build and verify scripts, CI wiring, docs.
Tech Stack: TypeScript, Playwright 1.56.1, Node.js stdlib for the recorder and site builder, GitHub Actions and Pages for publishing.
Live: spskelly.github.io/playwright-e2e-guides-template
Repo: GitHub

Overview

This is a Playwright template built around one idea: a user journey you already wrote as a test can also produce the guide that documents it, and the guide only exists if the test actually passed.

It came out of several consulting roles where I was responsible for test automation. Writing the tests meant walking the real click-paths through a product over and over, so I usually knew them better than the guides did.

The template’s own answer, stated in its docs, is that a passing test proves a screenshot or video frame matches current behavior on the day it was recorded, while a guide written by hand next to the code has no such proof. So the same Playwright journey runs twice: once fast, with no video or pauses, as a normal regression check, and once slow, with captions and screenshots on, as a recording. Only the recording’s output, and only if the underlying test passed, is eligible to reach the published site.

The more interesting decision is that “the test passed” is treated as necessary but not sufficient. A recording also has to survive a fingerprint check against the exact journey file, config, lockfile, and recorder code that produced it, and the finished site has to pass a separate link-and-asset audit before anything gets published.

The repo ships as a working example rather than a bare scaffold: one synthetic application (a local HTTP server with a fake sign-in and task list), one documented journey through it, and 38 tests across three npm scripts, none needing a database, cloud account, or paid API. It came together over 6 commits on a single day (2026-09-21, per git log), and holds about 1,800 non-blank lines of TypeScript and JavaScript across e2e/ and scripts/: roughly 700 in the application-independent recorder, config, and page objects, 570 in the record/build/verify/open scripts, and 510 in tests.

How a Test Becomes a Guide

graph TD
    APP["synthetic app: server adapter + mock API"] --> JOURNEY["one documented journey (.workflow.ts)"]
    JOURNEY -->|npm run test:journey, no video| FAST["fast regression check"]
    JOURNEY -->|npm run guides:record| STEPS["guide.step() wraps each action + assertion"]
    STEPS --> MANIFEST["manifest.json: steps, screenshots, webm, publishable"]
    MANIFEST --> CHECKPOINT["fingerprinted checkpoint in .guide-work"]
    CHECKPOINT -->|npm run guides:build| BUILD["inventory match, atomic staging"]
    BUILD -->|npm run guides:verify| VERIFY["every link and file the site promises"]
    VERIFY --> SITE["guides-site, the only thing CI publishes"]

A journey file (e2e/journeys/*.workflow.ts) calls guide.describe() once for metadata, then wraps each meaningful action in guide.step('title', async () => { ... }). The assertion that proves the step worked lives inside that callback, not after it, so a step that only clicks a button without checking the result can’t produce a “successful” recording. Each step() call takes a screenshot and still runs as an ordinary Playwright test.step, which is why the fast, video-off run and the slow, recording run are the same source file under two different Playwright projects (journeys and guides).

When the test finishes, a fixture teardown calls guide.finish(status) regardless of pass or fail, so a manifest.json always gets written, failure evidence included. But it computes a publishable flag from validation: status has to equal 'passed', every step needs a title, and every referenced screenshot has to exist on disk. One failed assertion anywhere in the journey means publishable: false, and nothing downstream touches that recording.

What “Validated” Means in Practice

“Validated” isn’t one boolean, it’s three gates that each have to hold:

  • At recording time, the manifest check above: status passed, steps present, screenshots exist.
  • At checkpoint time, record-guides.mjs hashes the journey file, config, lockfile, and recorder source into a fingerprint, and a checkpoint counts as reusable only if its stored fingerprint matches, status is passed, and its video file is present. Change any of those inputs and the checkpoint is stale, even if publishable: true still says otherwise.
  • At build time, guides:build cross-checks the checkpoint directory against the live list of journey files (missing, extra, or duplicate slugs all fail the build), then renders HTML, Markdown, captions, and a JSON index into a temporary directory and runs the same verifier CI runs afterward: does every guide have a README, an index.html, captions, a WebM, and every promised screenshot. Only then does the build atomically replace the previous guides-site with a rename, so a failed build never touches the last known-good site.

None of these checks look at whether the guide reads well. They only check that what’s published is a faithful, current, complete record of a journey that passed, a narrower claim than “this documentation is good,” and the docs make that scope explicit rather than implying more.

Checkpoints and Recording Timeouts

Recording (captions on, 250ms of slow motion, a pause after each step) is slower than testing, so guides:record treats each journey as a resumable unit, not an all-or-nothing batch. A checkpoint matching the current fingerprint is skipped and reused; a missing or stale one is re-recorded and renamed into place only after validateCheckpoint passes. A failed recording moves to a .failed-<slug>-<timestamp> directory instead of being deleted, so CI can upload it as diagnostic evidence. Each unit is capped at 9 minutes; the tool’s own --list output states the consequence plainly: the upper bound on a full run is journeys times 9 minutes. With one journey shipped, that bound is 9 minutes for a recording that finishes in seconds.

Privacy Is Handled by the Recorder, Not the Author

The recorder strips credentials, fragments, and any query parameter not on an explicit allowlist from every URL it records. Screenshots apply default masks (password and email inputs, anything tagged data-guide-mask) plus whatever a step adds, and a guide.sensitive() wrapper covers the whole page with an opaque overlay during an action, so credential entry never appears in a video frame even between screenshots. The docs stay honest that this is a mechanism, not a guarantee: docs/ADAPTING_THE_TEMPLATE.md says to inspect actual screenshots and video frames before enabling publication, because a passing test doesn’t prove private pixels are absent.

A Separate Gate for Publishing

Testing and publishing run as two GitHub Actions workflows with different trust levels. test.yml runs on every push and pull request with read-only permissions and no path to Pages. publish-guides.yml only runs when a repository variable, ENABLE_GUIDE_PAGES, is true, and that variable is absent by default so a freshly created repository from this template can’t publish before anyone has reviewed the output. Even enabled, only the final deploy job gets pages: write; the build job keeps read-only access. On this repo I set the variable on 2026-09-21 and ran the publish workflow by hand a minute later, which is why the live link above resolves to an actual guide.

Features

  • Guide fixture with three primitives - describe() for metadata, step() to wrap an action, assertion, screenshot, and caption together, sensitive() to blank the video during credential entry.
  • Manifest validation before anything is publishable - status, required fields, and screenshot existence, checked in e2e/guide/manifest.ts with 11 dedicated tests.
  • Fingerprinted, resumable checkpoints - a SHA-256 hash over the journey file, config, lockfile, and recorder source decides whether a prior recording can be reused.
  • Atomic site builds - the builder renames a validated temporary directory into place, keeping a backup until the rename succeeds.
  • A standalone verifier - guides:verify runs the same site-contract check whether it’s called right after a build or independently in CI.
  • URL and screenshot privacy defaults - credential and fragment stripping, a query-parameter allowlist, and configurable screenshot masks, defined once in guide.config.json.
  • Two Playwright projects, one source file - journeys runs the documented test with no video for speed, guides runs it with captions, slow motion, and recording on.
  • A publish gate that defaults to off - ENABLE_GUIDE_PAGES keeps a template-generated repository from auto-publishing before a human reviews the output.

Tech Stack

  • Testing: Playwright 1.56.1, TypeScript, four Playwright projects (contracts, example-app, journeys, guides) splitting fast checks from recordings in one config file.
  • Recorder and build scripts: Node.js standard library only, no build step, deliberately: the scripts deciding what gets published shouldn’t depend on a bundler working correctly.
  • Synthetic application: a local Node HTTP server and in-memory mock API (e2e/app), credentials on the reserved example.test domain.
  • CI: GitHub Actions, two workflows; testing runs read-only on every push and PR, publishing is gated behind a repository variable with Pages write access limited to the final deploy job.
  • Video/image tooling: Playwright’s built-in WebM recording and screenshot capture, with an optional ffmpeg step for MP4/GIF conversion that degrades gracefully when ffmpeg is absent.