Playwright Test Prompt
getByRole over CSS chains, auto-wait over sleep, web-first assertions — Playwright tests written the way Playwright wants.
Null, empty, min, max, off-by-one, malformed, unicode — the systematic boundary hunt that finds bugs where they actually live.
Edge cases are where the bugs live, and "also test some edge cases" finds none of them. This setup makes boundary hunting the strategy itself: partition the input space and test every partition edge — null/None/undefined at every entry, empty strings and collections, minimum and maximum values, just-inside and just-outside boundaries, malformed and wrong-type inputs, unicode and emoji in every text field — with failure scenarios for the compound edges: two boundary conditions arriving at once, maximum-size inputs meeting limits the happy path never sees.
Partition before you test
The strategy demands input-space partitioning — edges are found systematically, not brainstormed.
Test both sides of every boundary
Just-inside passes, just-outside fails — one without the other proves nothing.
Flag ambiguous boundaries
Where the code doesn't say whether 100 is inside, the contract tests both interpretations and says so.
The TEST STRATEGY tells the model to test both plausible interpretations and flag the ambiguity for any boundary the code leaves fuzzy, and the ASSUMPTIONS section makes it list every guess about unspecified behavior plus a GAPS list. So a fuzzy '<= 100 or < 100' yields tests for both plus a written flag, not a silent choice, wherever you run the prompt.
The FAILURE SCENARIOS block names the collisions single-input thinking misses: two edge conditions arriving at the same time, empty collections where the code assumes at least one element, and maximum-size inputs hitting limits the happy path never reaches. Each gets at least one test, so the generated prompt targets boundary pile-ups, not just a lone null.
The NON-GOALS pin the generated tests to the implementation as-is: do not rewrite or improve the code, do not refactor for testability, and never weaken assertions to make tests pass. Testability problems get flagged instead of patched. The prompt only asks for one runnable test file grouped by coverage area; running those tests and acting on the flags stays with you.
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.
Build a test suite that fails for real reasons, not green decoration — coverage across unit, integration, and edge cases, then a review for the gaps.
Ask AI for tests and you get a green suite that only checks the happy path and agrees with the code's bugs. Here's how to generate behavior-focused tests: give the model the intended behavior as the source of truth, cover boundaries and errors, and review them yourself.