/testing-automation:playwright-generate-testfrom testing-automation
Generates Playwright TypeScript tests from user scenarios by first exploring with Playwright MCP, then writing, running, and iterating until the test passes.
Ships in testing-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.
None: SKILL.md is the whole skill.
Generate a Playwright TypeScript test from a user scenario by first exercising the scenario with Playwright MCP, then writing the spec into the tests directory, executing it, and iterating until it passes.
@playwright/test is already present.tests directory. If the repository uses a nested Playwright convention such as tests/e2e, follow the existing convention inside tests.@playwright/test.tests directory with a descriptive .spec.ts name.npx playwright test <test-file> when the project has Playwright installed.| Scenario part | Capture | Test representation |
|---|---|---|
| Entry point | URL, route, fixture, auth state, viewport if relevant | await page.goto('<url>') or existing test fixture setup |
| User action | Clicks, fills, selections, keyboard input, uploads, navigation | page.getByRole, getByLabel, getByText, locator, selectOption, press |
| Observable result | URL change, visible message, table row, enabled control, network-driven UI state | await expect(...).toBeVisible(), toHaveURL, toContainText, toBeEnabled |
| Required wait | UI transition, navigation, async rendering | Prefer web-first assertions; avoid arbitrary sleeps |
| Test data | Unique names, emails, IDs, clean-up needs | Generate deterministic or unique data inside the test without hardcoded shared secrets |
| Preference | Use | Avoid |
|---|---|---|
| Accessible role | page.getByRole('button', { name: 'Save' }) | CSS class chains tied to styling |
| Form labels | page.getByLabel('Email') | Index-based selectors like locator('input').nth(2) |
| Stable test ids | page.getByTestId('submit-order') when the project uses them | Adding test ids without user approval unless already conventional |
| Visible text | page.getByText('Order submitted') for user-facing outcomes | Text that is dynamic, localized, or incidental |
| Structural locator | Scoped locator() only when accessible selectors are unavailable | XPath copied from browser devtools |
@playwright/test: import { test, expect } from '@playwright/test';.test.describe only when grouping multiple related tests in the same file.page.waitForTimeout.| Defect | Why it fails | Correction |
|---|---|---|
| Code before exploration | The test encodes assumptions and misses actual labels, routing, or timing | Complete all Playwright MCP steps before emitting code |
| Brittle selector | Styling or DOM order changes break the test without behavior changing | Use role, label, text, or test id selectors |
| Missing assertion | The test only clicks through the flow and can pass while the feature is broken | Assert visible outcome, URL, or persisted UI state |
| Arbitrary sleep | Slow or fast environments make waitForTimeout flaky | Use await expect(locator).to... |
| Unscoped data | Shared fixed values collide across runs | Generate unique data or clean up through existing helpers |
| Symptom | Likely cause | Resolution |
|---|---|---|
| Test cannot find a locator | The selected locator was not stable or the element appears later | Re-open the page with Playwright MCP, inspect accessible names, and replace with a web-first locator plus assertion |
| Test passes locally but fails in CI | Timing, viewport, auth state, or test data differs | Remove sleeps, assert readiness, use existing storage state or fixtures, and avoid shared data |
| Navigation assertion times out | The action does not navigate or the URL pattern is too strict | Assert the actual post-action UI state, or use a looser toHaveURL pattern backed by exploration evidence |
| Browser is not installed | Playwright dependency exists but browsers are missing | Run the project's documented install command, commonly npx playwright install, only when dependency setup is expected |
## Playwright test generation result
**Status:** passed | blocked
**Scenario:** <one-sentence scenario summary>
**Test file:** `tests/<name>.spec.ts`
### Exploration evidence
| Step | Interaction | Selector or URL | Observed outcome |
| --- | --- | --- | --- |
| 1 | <action> | `<selector-or-url>` | <visible result> |
### Generated test
- Framework: `@playwright/test`
- Command: `<test command>`
- Result: pass | fail
### Remaining work
- <none, or blocker with evidence>
@playwright/test.tests directory.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
13 skills in this plugin
/ai-prompt-engineering-safety-reviewReview and improve AI prompts for safety, bias, security, privacy, effectiveness, robustness, and testability. Use this skill when the user asks to audit a prompt, harden a system prompt, identify prompt injection risk, reduce bias, improve guardrails, or produce a safer enhanced prompt./csharp-nunitDesign, write, and review NUnit tests for .NET projects, including standard tests, data-driven tests, assertions, setup/teardown, categories, and isolation with mocks. Use this skill when the user asks for NUnit best practices, `dotnet test`, `[TestCase]`, `[TestCaseSource]`, or C# unit test structure./npx claudepluginhub gbb-acelerators/awesome-harness-primitives --plugin testing-automationOther plugins' skills for the same job