Goal
Given an OpenSpec file path, generate Playwright tests that model user flows as test cases, use stable selectors, assert real acceptance criteria, and avoid brittle timing.
Inputs
- •OpenSpec file:
$ARGUMENTS[0] - •Output directory (optional):
$ARGUMENTS[1], defaulttests/ui/generated
Output
- •One spec file per OpenSpec "User Flow" (or equivalent).
- •Write tests to:
<output-dir>/<slug>.spec.ts - •If needed, write shared helpers under
<output-dir>/_helpers/(page objects, login helper).
Core Workflow
1. Parse the OpenSpec
Follow the extraction procedure in references/parsing-rules.md:
- •Feature name / title (top heading)
- •Preconditions / Setup (logins, seed data)
- •User Flows (numbered steps)
- •Acceptance Criteria (assertions)
If any section is missing, infer minimally and add a TODO comment in the test file.
2. Generate test files
Apply the selector strategy and structure patterns in references/test-writing-rules.md.
Use the scaffold in templates/playwright.spec.ts.template as baseline structure.
See references/example-openspec.md for a worked example.
3. Post-generation checks
- •If
playwright.config.*exists, alignbaseURLusage. - •Run a quick syntax check:
bash
npx playwright test <generated-file> --reporter=line
- •If it fails due to missing app/server, do NOT start the server automatically unless the OpenSpec explicitly states the command.
Final Response
- •List created/modified files.
- •Provide the command to run the generated suite.
- •Call out any TODOs introduced.