playwright-recording-processor
Transforms raw Playwright codegen recordings into production-ready E2E tests through trimming, classification, and assertion injection. Use when processing codegen session recordings, trimming recorded browser sessions to a marker URL, classifying recordings as happy-path or bug-repro flows, or injecting diagnostic capture into reproduction tests. Invoke to convert a raw codegen recording into a maintainable test file or to build a bug reproduction test with console/network/state diagnostics.
Try your first task
A source-grounded starter task has not been verified for this skill yet.
SKILL.md
name: playwright-recording-processordescription: "Transforms raw Playwright codegen recordings into production-ready E2E tests through trimming, classification, and assertion injection. Use when processing codegen session recordings, trimming recorded browser sessions to a marker URL, classifying recordings as happy-path or bug-repro flows, or injecting diagnostic capture into reproduction tests. Invoke to convert a raw codegen recording into a maintainable test file or to build a bug reproduction test with console/network/state diagnostics."license: MITmetadata: author: https://github.com/dheerajc8073 version: "1.0.0" domain: quality triggers: codegen, recording, trim, marker URL, bug repro, diagnostic capture, session recording, Playwright codegen, recording processing, test generation role: specialist scope: implementation output-format: code related-skills: playwright-expert, test-masterPlaywright Recording Processor
Recording processing specialist that converts raw Playwright codegen output into structured, maintainable E2E tests.
Core Workflow
- Trim — Cut the raw recording at the exact marker URL path, discarding pre-feature navigation (via
scripts/trim-recording.tssaved fromreferences/trim-recording.mdor manual inline steps) - Classify — Determine flow type: happy path (feature coverage) or bug reproduction (diagnostic capture)
- Swap fixtures — Replace raw
pagereferences with custom fixtures (e.g.authenticatedPagefrome2e/fixtures.ts); update imports to loadtestfrom the project's fixture file - Harden — Replace brittle selectors with role-based locators (cross-ref
playwright-expert) - Assert — Inject assertions appropriate to flow type: checkpoint verification (happy path) or expected-outcome assertion with diagnostic capture in
finallyand screenshot capture intest.afterEach(bug repro)
Quick-Start Example
Transform raw recorded actions into an assertion-rich test using the auth fixture (assumes baseURL in playwright.config.ts):
// ❌ Raw recording (untrimmed with manual auth, hardcoded URL, no assertions)
// await page.goto('https://app.example.com/login');
// await page.getByLabel('Email').fill('user@example.com');
// await page.getByRole('button', { name: 'Sign in' }).click();
// await page.goto('https://app.example.com/invoices/export');
// await page.getByRole('button', { name: 'Download' }).click();
// ✅ Processed test (trimmed to marker URL, custom fixture, assertions added)
import { test, expect } from './fixtures';
// Source recording: recordings/raw-session-20240315.spec.ts (lines 14-22)
test('Invoice Export @happy-path', async ({ authenticatedPage: page }) => {
await page.goto('/invoices/export');
await expect(page.getByRole('heading', { name: 'Export' })).toBeVisible();
const downloadPromise = page.waitForEvent('download');
await page.getByRole('button', { name: 'Download' }).click();
const download = await downloadPromise;
expect(download.suggestedFilename()).toMatch(/\.csv$/);
});
Inputs Required
- Raw recording file — the
.spec.tsoutput fromnpx playwright codegen - Marker URL — the path where the feature under test begins (e.g.
/invoices/export) - Flow type — happy path or bug reproduction
- Auth fixture name and import path — e.g.
authenticatedPagefrom./fixturesfor a spec ine2e/; a spec inintegration/needs the path from there toe2e/fixtures.ts - Output target —
e2e/orintegration/depending on scope
If any of these are missing, ask before proceeding.
Flow Classification
Happy Path Flow
Use when:
- Testing a new feature for the first time
- Adding coverage for a release
- Tester followed a structured checklist
Output: A clean spec with the full user journey from marker URL to completion, using the existing auth fixture, with assertions added at key checkpoints.
Bug Reproduction Flow
Use when:
- A nontechnical user reported "the app broke"
- You need to capture what they actually did, in what state, on what browser
- The goal is a reproducible failing test to anchor a fix
Output: A spec that asserts the expected behavior (failing while bug is present) and captures full runtime diagnostic metadata (diagnostic-report) in a finally block (with failure screenshots captured via test.afterEach hook) so timeouts never lose diagnostics.
Reference Guide
Load detailed guidance based on context:
| Topic | Reference | Load When |
|---|---|---|
| Assertion Patterns | references/assertion-patterns.md | Adding assertions by UI element type |
| Trim Recording | references/trim-recording.md | Trimming raw codegen output, exact marker URL path |
| Bug Repro Diagnostics | references/bug-repro-diagnostics.md | Diagnostic injection, console/network/state capture |
Cross-References (from playwright-expert, not duplicated)
- For locator hardening patterns, see
playwright-expert(selectors-locators.md) - For Page Object Model and fixture patterns, see
playwright-expert(page-object-model.md) - For debugging flaky processed tests, see
playwright-expert(debugging-flaky.md)
Constraints
MUST DO
- Always trim to the exact marker URL pathname before processing
- Classify every recording before adding assertions
- Use role-based selectors from
playwright-expertpatterns when hardening - In bug repro flows, assert the expected behavior and attach
diagnostic-reportin afinallyblock (capturing failure screenshots viatest.afterEach) - Import
testfrom the project's fixture file when custom fixtures are swapped in - Annotate generated tests with source recording comments:
// Source recording: recordings/<name>.spec.ts (lines X-Y) - Assume
baseURLis configured; use relative paths for URLs from marker URL onwards
MUST NOT DO
- Process untrimmed recordings (pre-feature navigation noise pollutes tests)
- Add multi-step feature verification assertions to bug repro tests (only assert the single reported failure point)
- Generate tests without assertion injection (both happy-path and bug-repro tests require assertions)
- Duplicate locator/POM patterns already covered by
playwright-expert - Use
waitForTimeout()in generated tests (replace with auto-waiting web assertions or waitForURL)
Output File Placement
e2e/: Full journeys crossing multiple pages or system boundariesintegration/: Scoped to feature area; bug repros usually land hererecordings/: Archive only — raw files are never run directly
Checklist Before Handing Off
- Trimmed to exact marker URL path — no auth or pre-feature navigation
- Auth fixture swapped in and imported from project fixture file
- All locators are semantic (role, label, text) not positional
- Assertions added: checkpoint assertions (happy path) or expected-behavior assertion (bug repro)
- Diagnostic collection attached in
finallyblock underdiagnostic-report(bug repro) and failure screenshots captured viatest.afterEach - Any
waitForTimeout()calls removed and replaced with auto-waiting assertions - Source recording comment added at top of test
- Tagged correctly (
@happy-pathor@bug-repro) - Placed in correct output directory
- Raw recording archived untouched in
recordings/