Playwright Test Prompt
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.
Bad unit tests come from a missing philosophy: tests that hit the real database, tests named test1, tests asserting that mocks were called instead of that behavior happened. This setup generates the unit testing contract — every dependency mocked, business logic over plumbing, one behavior per test with names that state condition and result, fast and deterministic — plus the failure scenarios unit tests exist for: throwing dependencies, invalid arguments, boundary returns, and wrong-state calls.
Paste the unit, get the contract
The prompt carries isolation rules and failure scenarios — the model tests instead of improvising.
Check the mock boundary
Every external dependency mocked, nothing internal mocked — the line that keeps unit tests unit tests.
Read the ASSUMPTIONS block
Where the code's intent was ambiguous, the model says so instead of testing its own guess silently.
The TEST STRATEGY draws the line at the unit boundary: every external dependency (it names database, network, clock, filesystem) is mocked or stubbed, while nothing internal to the unit is. Generate the contract with the Test Case Prompt Generator and run it in ChatGPT, Claude, or Gemini; the model applies that rule, but you confirm the mock boundary matches your actual code before trusting the tests in CI.
Because the strategy tests business logic and decisions, not plumbing. Getters, mappers, and pass-throughs earn a test only when they carry a rule, so the model spends coverage on branches that make decisions instead of padding the file with trivial assertions. The generated prompt encodes that priority; the assistant you run it in still decides case by case, so review which methods it chose to skip.
The FAILURE SCENARIOS block names four that each get at least one test: a mocked dependency throwing, invalid arguments at every public entry point, boundary returns from dependencies (empty result, null, maximum size), and state-dependent behavior called in the wrong state. The prompt makes the model attempt all four; you still run the resulting tests to confirm each path actually triggers as asserted.
Read the ASSUMPTIONS and GAPS headings the OUTPUT FORMAT requires after the test file. ASSUMPTIONS list guesses the model made about unspecified behavior; GAPS list behaviors it could not test with the information given. Treat GAPS as a to-do list: feed the missing context back into the prompt and regenerate, rather than shipping those untested paths unexamined.
getByRole over CSS chains, auto-wait over sleep, web-first assertions — Playwright tests written the way Playwright wants.
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?
Build the test set an agent has to pass — scenarios across the happy path, edges, and adversarial inputs, each paired with the expected behavior to grade against.
"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.
The full path from idea to a shipped SaaS MVP — define and scope the requirements, design the architecture, API, and data model, then build it reviewed, tested, secured, cost-controlled, and deployed.
The full path to a backend you can put clients on — define the requirements, design the architecture, API contract, data model, and access control, then build it reviewed, tested, secured, and shipped.
The full path to taming an inherited codebase — understand it, document its architecture, pin its behavior with tests, then refactor, modernize, review, speed up, and ship it without breaking what works.
The full path to a two-sided platform — define the buyer-and-seller requirements, model the data, design the API, build roles and permissions, wire integrations, design the UI, then test, secure, and ship it.
The full path to a store you own end to end — model the catalog and orders, design the storefront and checkout, add customer accounts and payments, then secure it, test it, and ship.
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.