Code prompts
Code prompt

Write tests for this function (with edge cases I haven't thought of)

You have a function and need test coverage. The boring tests are easy. The edge cases are what catch real bugs.

Works best in: Claude

Write tests for this function. Include edge cases I probably didn't think of.

Code:
```{{language}}
{{paste function}}
```

Test framework: {{Jest / Vitest / pytest / etc.}}

Output:
1. **Happy-path tests** (3-5) — normal usage
2. **Boundary tests** — empty input, max input, min input, edge of valid range
3. **Failure modes** — invalid inputs, malformed data, dependencies missing
4. **Sneaky cases** — things that look like edge cases but are actually correct behavior worth pinning down
5. **What I should test but can't easily here** — flag anything that needs integration tests, not unit tests

For each test, one-line comment explaining what scenario it pins down.
·Open in·Share
testingedge casesunit tests

More code prompts

All code prompts

Go deeper