/playwright-automation:review-test-codefrom playwright-automation
Quality review of Playwright test code before final execution signoff. This skill should be used when implementation review of executable Playwright tests is needed, not for diagnosis of runtime flakiness. Triggers: "review test code", "review Playwright tests", "check test quality", "audit test implementation", "review my tests before merging", "check test code for issues", "review e2e tests", "code review Playwright", "are my tests stable", "check for brittle selectors", "review before running tests". Quality gate after write-test-code — catches brittle selectors, force:true misuse, networkidle overuse, Tailwind utility class selectors, exact numeric assertions, missing teardown, parallel-unsafe mutations, hardcoded data, missing assertions, test coupling, and convention divergence. Review-only — does NOT rewrite tests, does NOT run tests. Use fix-flaky-tests for fixing, write-test-code for rewriting.
Ships in playwright-automation. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Review Playwright test code for stability, correctness, and adherence to project conventions before final execution signoff. This is a quality gate — catch structural issues in code before running tests, not after flaky failures.
Execution context: this review must run in a fresh subagent, not the agent that authored the code. The orchestrator enforces this via the Task tool; the skill documents the contract so a drifting caller can see they're breaking it. Self-review reliably misses the gaps the author anchored on — passing only the file path (not the authoring transcript) into a new Task call is the cheapest way to get an independent read.
Parse the test file path or directory from: $ARGUMENTS
If no argument provided, search for recently modified *.spec.ts or *.test.ts files and review those.
playwright.config.ts or playwright.config.js — extract baseURL, testDir, projects, timeouts, fullyParallel, workersdocs/qa/conventions.md if it existsdocs/qa/test-cases/<feature>.md) if it exists — needed for traceability checkEvaluate the test code against each criterion. Track findings by severity:
Treat evidence-sensitive workarounds separately from ordinary style issues:
{ force: true }, JavaScript-dispatched clicks, guessed coordinate clicks, page-wide text oracles, or broad CSS fallbacks are used without fresh browser evidence at the execution conditions or without explicit reviewer/operator acceptance.| Check | What to Look For |
|---|---|
| Semantic locators preferred | getByRole, getByLabel, getByPlaceholder over CSS selectors |
| No fragile positional selectors | .first(), .nth(), .last() without documented justification |
| No dynamic IDs or classes | Selectors containing generated hashes, UUIDs, or auto-incremented values |
| No utility framework classes | Selectors must not contain Tailwind (rounded-lg, flex, bg-*), Bootstrap (btn-primary, col-md-*), or similar utility classes — these are styling, not identity |
| Scoped to containers | Locators narrowed to main, nav, [role="dialog"] where needed |
| No exact long text matches | Use regex with key words instead of full marketing copy |
When a locator appears suspicious, delegate verification to a subagent (Task tool): instruct it to open the target URL, locate the element using the browser MCP tools (find, get_element), and report back whether the element exists and is unique.
Mandatory re-exploration triggers:
{ force: true }, JavaScript clicks, coordinate clicks, page-wide text oracles, or broad CSS selectors because semantic selection failedIn those cases, report an evidence gap and require fresh browser evidence before signoff.
| Check | What to Look For |
|---|---|
No waitForTimeout() | Arbitrary sleeps mask real timing issues |
| Proper action-response waits | waitForResponse before asserting API-dependent UI |
| Auto-retrying assertions used | await expect(el).toBeVisible() not expect(await el.isVisible()).toBe(true) |
| Reasonable explicit timeouts | Custom timeouts ({ timeout: 10000 }) have a comment explaining why |
No networkidle overuse | networkidle is fragile; prefer specific response waits |
| Check | What to Look For |
|---|---|
| Every test has assertions | No test blocks without expect() calls |
| Assertions test user outcomes | Visible text, URL changes, element states — not internal state or CSS classes |
| Assertions are specific | toHaveText('Welcome, John') not just toBeVisible() |
| Error paths have assertions | Error scenario tests verify the error message, not just that "something happened" |
| No exact server-computed values | Dashboard counters, totals, and aggregates must not assert exact numbers — use patterns, ranges, or seed data first |
No toBeTruthy() on locators | Use Playwright-specific matchers (toBeVisible, toBeEnabled, toHaveText) |
| Action-vs-assertion balance | For each TC that claims to verify behavior, verify the test actually triggers the action (click, type, navigate, submit) AND asserts the resulting state. A test that only asserts toBeVisible() on an element the test never clicked or interacted with is visibility coverage masquerading as functional coverage — BLOCKER. Example pattern to flag: await expect(page.getByRole('button', { name: /save/i })).toBeVisible() with no preceding click() or fill() in the same test. |
| Check | What to Look For |
|---|---|
| No shared mutable state | Tests do not depend on execution order or modify shared variables |
| Proper setup/teardown | beforeEach/afterEach for shared setup, not duplicated in each test |
| AAA structure | Clear Arrange → Act → Assert sections (comments optional but structure required) |
| No test coupling | Test B does not depend on side effects from Test A |
| Auth handled correctly | storageState or fixture, not UI login in every test (unless testing login itself) |
| Test data is unique | Uses Date.now(), factories, or unique IDs — not hardcoded shared data |
Parallel-safe (if fullyParallel: true or workers > 1 found in config) | Tests that create data must not assert on unscoped lists or counts — filter assertions to the specific data created. If parallelism is disabled, note as SUGGESTION rather than WARNING |
| Data cleanup present | Tests that create persistent records (API POST/PUT) must have corresponding teardown (afterEach, fixture cleanup, or globalTeardown) |
| Check | What to Look For |
|---|---|
| TC-ID in test title | Every test has TC-<FEATURE>-<NNN>: Description format |
| File naming matches project | Follows existing *.spec.ts or *.test.ts convention |
| Import style matches project | Imports from project fixtures file if one exists, not raw @playwright/test |
| baseURL used | page.goto('/') not page.goto('https://example.com/') |
| POM pattern followed (if used) | Page objects for interactions, tests for assertions |
| Consistent locator strategy | Same locator approach as existing tests |
If a test case spec file exists for this feature:
Flag any instances of these known anti-patterns:
waitForTimeout() used as a fix.first() / .nth() without justificationexpect(await el.isVisible()).toBe(true) instead of await expect(el).toBeVisible()await on Playwright calls (easy to miss, causes silent failures){ force: true } on interactions without documented justification (masks actionability issues — overlapping elements, disabled state, not scrolled into view)waitForLoadState('networkidle') as default wait strategy — breaks on long-polling, WebSockets, analytics beacons; use specific waitForResponse or UI assertions insteadrounded-lg, flex, Bootstrap btn-primary, col-md-*) — styling classes are volatile, never use as selectorstoHaveText('12450')) — use pattern matchers, ranges, or seed data to control expected valuestoBeVisible() or toHaveCount() on elements the test never interacted with. A render check is not a behavior check. Either add the action (click, type, submit) that the test claims to verify, or recategorize the test honestly as a smoke/render check and cap its count.Output a structured review with this format:
# Test Code Review: <file or feature>
**Files reviewed:** <list>
**Total tests:** <count>
**Review date:** <date>
## Verdict: PASS | PASS WITH WARNINGS | NEEDS REVISION
## Blockers (<count>)
- **<file>:<line>** `<test name>`: <issue description>
## Warnings (<count>)
- **<file>:<line>** `<test name>`: <issue description>
## Suggestions (<count>)
- **<file>:<line>**: <issue description>
## Convention Divergences
- <How this code differs from the project's established patterns>
## TC-ID Traceability
- **Implemented:** <count> / <total in spec>
- **Missing from implementation:** <list of TC-IDs>
- **Orphaned (no spec):** <list of TC-IDs>
## Summary
<2-3 sentences on overall code quality and what to address before test execution>
{ force: true }, JS clicks, guessed coordinate clicks, page-wide text/count oracles, and broad CSS fallbacks are blockers unless backed by fresh browser evidence, a documented platform limitation, or explicit acceptanceawait is a blocker; a naming style preference is a suggestion/review-test-code tests/e2e/login.spec.ts
/review-test-code tests/e2e/
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub lespaceman/athena-workflow-marketplace --plugin playwright-automation5 skills in this plugin
/add-playwright-testsTHE DEFAULT ENTRY POINT for the Playwright execution layer in the split testing suite. Use to add, create, or set up Playwright end-to-end tests for a feature, page, or application. It orchestrates the full Playwright workflow after shared exploration and planning: analyze the Playwright codebase, consume `docs/qa/feature-map.md`, `docs/qa/exploration-report.md`, `docs/qa/coverage-plan.md`, and `docs/qa/test-cases/*.md`, write production-grade test code, review it, and verify it with real execution. Delegates to `analyze-test-codebase`, `write-test-code`, `review-test-code`, and `fix-flaky-tests`, while relying on shared `map-feature-scope`, `capture-feature-evidence`, `plan-test-coverage`, `generate-test-cases`, and `review-test-cases`.
/analyze-test-codebaseScans and reports on an existing Playwright test codebase. This skill should be used to inspect the current Playwright setup before writing, reviewing, or fixing tests, and should be loaded early when working in a new project to understand existing patterns. Covers: Playwright config, page objects, fixtures, helpers, auth/globalSetup patterns, test conventions, and directory structure. Triggers: "understand", "check", "show me", "inspect", or "analyze" the current test setup, config, infrastructure, patterns, or conventions. In the full add-tests workflow, this skill serves as an early read-only analysis sub-step before planning detailed coverage or writing code. This skill examines existing files and outputs a structured report. It does NOT write or fix tests, install Playwright, or explore live websites — for live-site exploration, use `capture-feature-evidence` so evidence is captured in `docs/qa/exploration-report.md`.
/fix-flaky-testsThis skill should be used when a Playwright test is failing, flaky, timing out, or behaving inconsistently. It provides structured root cause analysis for: stabilizing intermittent tests, debugging timeouts ("Test timeout of 30000ms exceeded"), fixing race conditions, investigating local-vs-CI divergence, running repeated stability checks (--repeat-each). IMPORTANT: If running tests with --repeat-each, --retries, or multiple times to check stability, STOP and load this skill first — it has structured root cause analysis that prevents brute-force approaches. Triggers: "stabilize", "intermittent", "flaky", "keeps failing", "fails in CI", "timeout on", "race condition", "run N times to check stability", "verify tests are stable". NOT for writing new tests (use write-test-code) or analyzing setup (use analyze-test-codebase).
/write-test-codeThis skill should be used when writing, refactoring, or modifying Playwright E2E test code. It covers creating test files from TC-ID specs, converting browser exploration results to executable tests, refactoring locators or fixtures, adding API mocking, test data setup/teardown, and parallel-safe isolation. Includes locator strategy hierarchy, auth setup patterns, fixture design, teardown strategies, and network interception recipes. Triggers: "write a test for", "add a test case", "refactor this locator", "add error path tests", "convert specs to code", "add API mocking", "set up auth for tests". NOT for: full pipeline from scratch (use add-playwright-tests), shared live-site exploration (use capture-feature-evidence), generating specs without code (use plan-test-coverage or generate-test-cases), diagnosing flaky tests (use fix-flaky-tests).