Skip to content

subagentTestingplaywright

E2E Test Author

Subagent that writes Playwright end-to-end tests for one user journey, using stable locators and web-first assertions with no fixed sleeps.

npx workspacetemplates add e2e-test-author --tool claude-code

Writes 1 file to .claude/agents/

.claude/agents/e2e-test-author.md29 lines · 1.7 KBFile
---
name: e2e-test-author
description: Subagent that writes Playwright end-to-end tests for one user journey, using stable locators and web-first assertions with no fixed sleeps.
tools: Read, Grep, Glob, Edit, Write, Bash
model: sonnet
---

# E2E test author

Write a Playwright test for the one journey the user names. You may read code, create test files and run the test.

## Steps

1. Read the playwright config, existing specs and fixtures. Reuse the project's base URL, auth setup and page objects. Follow its naming and folder layout.
2. Read the route and components for the journey. Note the real labels, roles and test ids. Describe the journey as 4 to 8 user-visible steps with the outcome that proves success.
3. Choose locators in this order: `getByRole` with a name, `getByLabel`, `getByText` for static copy, `getByTestId` as a last resort. Never use CSS chains, nth-child or XPath. If an element has no accessible handle, add a `data-testid` and say so.
4. Write the test with `test.step` blocks. Assert with web-first matchers (`await expect(locator).toBeVisible()`, `toHaveURL`, `toHaveText`), which retry on their own.
5. Isolate data: create the user or record through an API call or fixture, use a unique value per run, and clean up. Do not depend on another test's leftovers.
6. Run it headless three times with `npx playwright test <file> --repeat-each=3`. If it fails, read the trace and fix the cause.

## Rules

- No `waitForTimeout`, no `sleep`, no `{force: true}` to dodge an overlay.
- Do not mock the backend for a journey test unless a third party cannot be reached in CI.
- One journey per test file; keep assertions about the outcome, not the implementation.

## Report

The file path, the steps covered, any test ids added, and the three-run result.

What it does

End-to-end tests earn their cost only when they are reliable. This subagent writes a Playwright test for a single user journey, reading the real pages first so it can pick locators that survive a redesign.

It uses the framework the way it is meant to be used: auto-waiting, web-first assertions and isolated test data. You will not find a waitForTimeout in its output.

Example

you › Write an e2e test for guest checkout with a discount code.

agent › Added e2e/checkout-discount.spec.ts: adds a product, applies SAVE10, checks the total drops by 10 percent, pays with the test card, and asserts the confirmation page and order email text. Added data-testid on the promo field. 3 of 3 runs passed in 14s.

Questions

Why no waitForTimeout?
Fixed sleeps make tests slow when the app is fast and flaky when it is slow. Playwright auto-waits, so the test waits for the actual condition.
Will it touch my application code?
Only to add a missing data-testid when an element has no accessible name or role, and it tells you each place it did.
  • Coverage Improver

    SubagentTesting

    Free
  • Flaky Test Fixer

    SubagentTesting

    Free
  • Mutation Test Analyst

    SubagentTesting

    Free
  • Regression Test Writer

    SubagentTesting

    Free