Coding
Write tests that would actually catch bugs
Produces tests focused on failure modes rather than restating the happy path.
Prompt
Write tests for this code.
Framework: {{framework}}
What it's supposed to do: {{purpose}}
```
{{code}}
```
Priorities, in order:
1. Edge cases most likely to break it in production
2. Boundary values (empty, zero, one, maximum, null/undefined)
3. Error paths — what happens when a dependency fails
4. The happy path — last, and briefly
For each test, add a one-line comment saying what real failure it would catch.
Do not write tests that only assert the implementation restated. If a test wouldn't catch a plausible bug, don't write it.Fill these in
Replace each highlighted variable before sending. Leaving them in place is the most common reason these prompts under-perform.
| Variable | What to put | Example |
|---|---|---|
{{framework}} | Test framework | Vitest |
{{purpose}} | Intended behavior | Validate and normalize a phone number |
{{code}} | Code to test | Paste the function |
Tips for better output
- The "what failure would this catch" comment kills tautological tests immediately.
- Ordering edge cases first means you get the valuable tests even if you stop reading early.