Playwright Test Prompt
getByRole over CSS chains, auto-wait over sleep, web-first assertions — Playwright tests written the way Playwright wants.
Status codes, response shapes, 401 vs 403, idempotency — API tests that test the contract, not the implementation.
API tests that only check 200-and-some-JSON miss what APIs break: the 400 that comes back as a 500, the 401/403 confusion that leaks resource existence, the error body whose shape nobody asserted. This setup generates the API contract test suite: every response asserting status code, body shape, and meaningful headers; auth as behavior (missing credentials → 401, wrong permissions → 403 — different tests); error responses held to their contract as strictly as success; idempotency of repeated requests; and payload limits enforced at the documented boundary.
Test the contract, not the code
Request in, response out — the suite holds the documented behavior, whatever the implementation does inside.
Separate the auth tests
401 for who-are-you, 403 for you-can't — one test each, never merged.
Repeat the dangerous requests
The idempotency scenario: send the completed request again and assert the documented behavior, not luck.
They assert different behavior, so the prompt writes one test each: 401 covers missing, expired, or malformed credentials, while 403 covers a valid caller whose role is forbidden. Merging them hides the case where a wrong-permission request leaks whether the resource even exists, and a single failure message would no longer tell you which auth rule broke.
The FAILURE SCENARIOS block already targets this: 'Invalid payloads return 400 with the documented error shape — not 500,' so a swallowed 500 fails the test instead of passing quietly. Paste the endpoint into CODE CONTEXT with its documented error body, and the generated tests assert both the status code and that error shape.
The FAILURE SCENARIOS marker 'a duplicate of a completed request behaves as specified' becomes at least one test, but 'as specified' is only as good as what you supply. Define your endpoint's idempotency contract in CODE CONTEXT — same response, no second charge, a 409, whatever applies — and the prompt writes the repeat-request assertion around it.
Not on their own. This resource produces a test-writing prompt via the Test Case Prompt Generator; you run it in ChatGPT, Claude, or Gemini to get a runnable test file, then run that file in CI. Passing tests confirm only the assertions they hold — check the prompt's ASSUMPTIONS and GAPS output for unspecified behavior it flagged rather than covered.
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.
Code you can refactor on a quiet afternoon. A field you shipped is somebody else's dependency — you don't fix it, you version it. What an hour of contract review buys: method semantics, a truthful error model, retries, authorization, and compatibility you didn't mean to promise.