Unit Test Writer
Writes unit tests for a function you paste. Covers happy path, edge cases, and error cases. Skips the ones that would just test the language.
The prompt
I'll paste a function. Write unit tests for it in the appropriate framework (Jest / Vitest / Pytest / Go test — infer from the language, or ask if unclear).
Structure:
**Happy path** — 2-3 tests covering the expected use.
**Edge cases** — empty input, null, negative numbers, unicode, boundary values, huge input. Only include the ones that actually apply to this function.
**Error cases** — invalid types, out-of-range values, malformed input. Include the error class or message you expect.
**What I did NOT test** — one paragraph on what's out of scope and why (external dependencies, timing, randomness). No point pretending we covered everything.
Rules:
- No test that would just verify the language works ("test that adding 2 + 2 = 4" for an add function).
- Use `describe`/`it` structure with clear names.
- One assertion per test where possible; multiple if they check the same behavior from different angles.
- Mock external calls; don't hit the network.
## How to use it
Paste this prompt, then paste your function. Get tests you can drop into your test file. Read "What I did NOT test" to know where you still need integration or manual testing.
## Why it works
Most AI-generated tests are either exhaustive to the point of noise, or so shallow they miss the actual bugs. Forcing the "what I did NOT test" section keeps the scope honest. How to use it
I’ll paste a function. Write unit tests for it in the appropriate framework (Jest / Vitest / Pytest / Go test — infer from the language, or ask if unclear).
Structure:
Happy path — 2-3 tests covering the expected use.
Edge cases — empty input, null, negative numbers, unicode, boundary values, huge input. Only include the ones that actually apply to this function.
Error cases — invalid types, out-of-range values, malformed input. Include the error class or message you expect.
What I did NOT test — one paragraph on what’s out of scope and why (external dependencies, timing, randomness). No point pretending we covered everything.
Rules:
- No test that would just verify the language works (“test that adding 2 + 2 = 4” for an add function).
- Use
describe/itstructure with clear names. - One assertion per test where possible; multiple if they check the same behavior from different angles.
- Mock external calls; don’t hit the network.
How to use it
Paste this prompt, then paste your function. Get tests you can drop into your test file. Read “What I did NOT test” to know where you still need integration or manual testing.
Why it works
Most AI-generated tests are either exhaustive to the point of noise, or so shallow they miss the actual bugs. Forcing the “what I did NOT test” section keeps the scope honest.
✦ More like this
Related prompts
Book Recommender (Honest)
Recommends 3-5 books based on what you actually liked before. No 'Sapiens for the 400th time.' Includes honest reasons and what NOT to expect.
Chart Type Chooser
Given the data you have and the question you're answering, picks the right chart type and explains what to avoid. No dual-axis, no pie chart traps.
Code Refactor Helper
Refactors a function or file without changing behavior. Explains what changed and why, and flags any behavior it wasn't sure about.