| name | playwright-generate-test |
| description | Generate a Playwright TypeScript E2E test for a given scenario. Navigates the app step-by-step, uses role-based locators, and saves the test in tests/e2e/. |
Goal
Generate a Playwright test based on a user-provided scenario. If no scenario is provided, ask for one first.
Rules
- Do NOT generate test code prematurely — run the actual steps first using Playwright MCP tools.
- Use
@playwright/test with TypeScript.
- Save all test files in
frontend/tests/e2e/.
- Name files
<feature>.spec.ts (e.g., auth.spec.ts, editor.spec.ts).
- Execute the generated test and iterate until it passes.
Locator Priority (do not use CSS class or XPath)
getByRole()
getByLabel()
getByText()
getByPlaceholder()
getByTestId() — only when semantic locators aren't possible
Assertion Rules
- Use web-first assertions:
await expect(locator).toHaveText(), toHaveURL(), toBeEnabled().
- Never use
waitForTimeout().
- Rely on Playwright's built-in auto-waiting.
Test Structure Template
import { test, expect } from '@playwright/test';
test.describe('Feature Name', {
test.( ({ page }) => {
page.();
});
(, ({ page }) => {
test.(, () => {
});
test.(, () => {
(page.(, { : })).();
});
});
});