Playwright Test Prompt
getByRole over CSS chains, auto-wait over sleep, web-first assertions — Playwright tests written the way Playwright wants.
Cart to confirmation as a user would do it — with the failure scenarios real users actually trigger: refreshes, back buttons, double clicks.
End-to-end tests written like unit tests waste a browser: they poke at elements instead of walking journeys. This setup generates the E2E contract for a checkout flow at production-ready depth: realistic workflows from entry to outcome, minimal mocking (only true externals like payments), assertions at both ends — what the user sees and what the system stores — and the failure scenarios that separate E2E from demos: mid-flow refresh, slow networks, expired sessions, double-submission, and the back button revisiting a completed step.
Define the journey, not the pages
Entry to outcome — the contract tests what the user is trying to accomplish.
Keep the failure scenarios
Refresh, back button, session expiry, double submit — the four ways real users break flows daily.
Assert both ends
The confirmation the user sees AND the order the system stored — a journey that only checks one end checks nothing.
Five listed under FAILURE SCENARIOS, each getting at least one test: the user refreshes or navigates away mid-flow, a slow network turns instant steps into waits, the session expires between steps, the user double-submits the final action, and the back button revisits a completed step. It generates the Playwright test file for these; you run the suite and confirm it against your real stack.
To survive UI churn and stay CI-safe. FRAMEWORK GUIDANCE locates by user-facing attributes — getByRole, getByLabel, getByText — not "CSS chains that break on restyle," and says "Never sleep: rely on auto-waiting and web-first assertions." Flaky patterns are treated as defects in the tests. The prompt produces one runnable file; you execute it and own whether it passes.
It generates tests, it doesn't diagnose. The instruction is "Generate tests only — do not modify the implementation," and the notFor line sends "Diagnosing why a flow currently fails" to the Debugging Prompt Generator. Use this to pin behavior — asserting both what the user sees and what the system stores — and use debugging when you need a root cause.
getByRole over CSS chains, auto-wait over sleep, web-first assertions — Playwright tests written the way Playwright wants.
Mock the dependencies, test the business logic, one behavior per test — the unit testing contract that bans plumbing tests.
Test the two failure directions — does the agent refuse what it must, and does it stay helpful on the benign requests it shouldn't over-refuse?
"Review this code" gets shallow comments. The review contract gets findings with severities, a checklist, and a verdict.
"Fix this error" gets guesses. The investigation contract gets a ten-stage diagnosis: facts separated from assumptions, alternatives weighed, fixes justified.
The JSON won't parse and you can't see why. Deterministic cause-sniffing — trailing commas, single quotes, unclosed brackets — and the repair prompt that fixes it.
Build test generation prompts — unit, integration, or E2E — with framework modes and edge-case coverage rules.