THE REPLACEQA BLOG

User journey monitoring with Playwright: build your first check

Build a Playwright user journey check, run it on a schedule, preserve failure evidence and define who responds when the journey breaks.

User journey monitoring starts with a browser check that verifies a customer outcome. Run that check repeatedly, retain its results, and give someone responsibility for failures and missing runs. A script that passes once is the beginning of that system.

This guide builds one public search journey with Playwright. The runnable example uses a fictional template catalog, so you can break and repair the behavior without touching customer data. The accompanying workflow shows how to schedule an adapted check in GitHub Actions. The browser example was exercised locally; the hosted workflow and its notifications have not been tested in a GitHub repository.

Define the outcome before writing the script

Our catalog contains a controlled record called “Weekly review,” with the identifier weekly-review. The requirement is: a visitor searches for “weekly,” opens the matching result, and reaches that template's detail page.

That is narrower than “the catalog works.” It does not cover every query, private templates, editing or billing. It also needs a stable fixture: if someone intentionally removes the seeded record, the check will need a new agreed expectation.

Use a short contract like this before automating your own journey:

QuestionExample answer
Where does the visitor start?Public catalog, fresh browser session
What do they do?Search for weekly, then open Weekly review
What must be true afterward?Correct URL, heading and template identifier
Does this create data?No; this fixture only reads the catalog
Who reviews a failure?The developer responsible for catalog releases

If you are still choosing which journeys matter, start with the small-team testing strategy. The uptime comparison explains why an HTTP response alone cannot verify this task.

Run the browser check

Download the runnable examples, extract the archive and open its directory. With Node.js 22 installed, run:

npm ci
npx playwright install chromium
npx playwright test tests/journey.spec.js

The included configuration starts a local fixture at http://127.0.0.1:4319 and stops it after the test. The test uses the fixture's specific contract:

import { test, expect } from '@playwright/test';

test('a visitor can find and open the weekly review template', async ({ page }) => {
  await page.goto('/catalog');
  await page.getByRole('textbox', { name: 'Search' }).fill('weekly');
  await page.getByRole('button', { name: 'Search', exact: true }).click();
  await page.getByRole('link', { name: 'Weekly review', exact: true }).click({ timeout: 2_000 });
  await expect(page).toHaveURL(/\/templates\/weekly-review$/);
  await expect(page.getByRole('heading', { name: 'Weekly review', exact: true })).toBeVisible();
  await expect(page.getByRole('main')).toHaveAttribute('data-template-id', 'weekly-review');
});

Each assertion answers a different question. The URL checks the destination; the heading checks visible content; the identifier ties that content to the controlled record. Change these together when adapting the example to your application. Do not preserve the sample title while pointing the test at an unrelated site.

The configuration fixes Chromium, viewport and locale, uses no whole-test retries by default, and keeps traces and screenshots when a test fails. Its short assertion timeouts suit a local teaching fixture. Choose timeouts for your own service's expected behavior and investigate persistent slowness instead of indefinitely extending them. Playwright documents these controls in its configuration reference.

Break the journey and check the evidence

In a Linux or macOS shell, run:

DEMO_FAULT=search npx playwright test tests/journey.spec.js
npx playwright test tests/journey.spec.js

The first command deliberately removes the expected search result. It should exit unsuccessfully at the result-opening step. The second starts a new, healthy fixture. During local validation, the healthy, broken and restored runs produced pass, fail and pass respectively. The archive's evidence.json records those executions with Playwright Test 1.63.0.

Open the failed run's trace before overwriting its output with another command, or copy the result directory first. A failure without its original evidence is harder to explain. Our trace investigation guide walks through that review.

Want help preparing a public journey check for your site? ReplaceQA’s closed beta discovers public journeys, generates Playwright source and retains validation evidence for review. Request beta access. Run recurring checks separately; scheduling is not currently included.

Schedule the adapted check

The archive includes journey-workflow.yml. It assumes the example package and lockfile are at the root of a separate repository. Copy it to .github/workflows/journey.yml, adapt the test, and set the repository variable JOURNEY_BASE_URL to your deployment's public origin.

The template checks out the source, sets up Node.js, installs the locked dependencies and Chromium, runs only the journey test, and uploads test-results/ even if the test fails. Its triggers are:

on:
  workflow_dispatch:
  schedule:
    - cron: '17 * * * *'

That requests an hourly run at minute 17 using the default UTC interpretation. With BASE_URL set, the example configuration connects to the supplied deployment instead of starting the local fixture. The workflow rejects an empty URL so a missing setting cannot silently turn the monitor into a local demo run.

First use the manual trigger against a compatible test deployment. Introduce a controlled failure there and confirm that the job fails, evidence uploads and the intended reviewer receives a notification. Check the recovery path too. These hosted checks are setup steps for your repository; they are not results claimed by our local example.

GitHub warns that scheduled runs can be delayed and, under enough load, dropped. Scheduled workflows also depend on the default branch and can be disabled after inactivity in public repositories. Use its schedule documentation when deciding whether this mechanism meets your operational needs.

Treat a missing run as a separate condition

An old green result is not evidence that a journey still works. Our workflow template does not implement an independent missing-run alert. Until you add one, that remains a coverage gap.

For a hypothetical hourly check, your worksheet might require review when no execution has completed for two hours. That is a team choice, not a universal threshold. An independent watchdog could evaluate the last completed run, while the ordinary failure notification handles an executed check that returned a failure. The distinction matters because a workflow that never starts cannot report its own absence.

Record the decisions explicitly:

ConditionEvidence to inspectResponse
Browser assertion failsFailed step, trace, target and releaseJourney owner assesses customer impact
Runner cannot startJob logs and dependency/environment errorsRestore the check and preserve the coverage gap
No recent completed runLast execution timestampInvestigate scheduling or runner availability
Check passes after repairNew result alongside the original failureConfirm the same customer transition now works

Keep checking your important customer journeys.

Explore ReplaceQA ↗