Write tests for the behavior
Covers one behavior with tests in the runner the repo already uses. No tests of internal details.
When to use it
Use when the function or route exists and has no test, or the test only asserts that a mock was called.
Variables
[AREA][BEHAVIOR][RUNNER][DO_NOT_MOCK]
Copy prompt
Write tests for [AREA]. Behavior that must stay locked: [BEHAVIOR]. Runner and command: [RUNNER]. Do not mock: [DO_NOT_MOCK]. Rules - Use only [RUNNER]. Do not add Jest, Vitest, Pytest, or another runner. - Test observable behavior: return value, HTTP status, visible text, a row that was written. Do not test that an internal function was called, unless that is the contract. - Cover the happy path, one invalid case, and one edge named in [BEHAVIOR]. If no edge is obvious, ask before inventing one. - What is listed in [DO_NOT_MOCK] uses the real implementation or a file fixture. You may mock external network and the clock. - Do not change production code to make the test pass, except to inject a clock or a temp directory. If you need a larger change, stop and explain. - The test name describes the behavior, not the method. Deliver 1. The test file. 2. The output of [RUNNER] for these tests only. 3. If a test passed without executing [AREA], delete it and rewrite it. If [AREA] does not exist in the repo, stop. Do not create the feature.
How to run this prompt
- Describe the behavior. One sentence from the caller's point of view, not the file's.
- Name the runner. The command that already exists in package.json or the Makefile.
- Run it and read the failure. A new test that passes without exercising the code is suspicious.
Where this breaks
The model tests implementation (how many times a helper ran). DO_NOT_MOCK lists what must stay real. If the runner is wrong, it will install another one: the prompt forbids that.
Result
Slot for a screenshot or demo. No result is published yet.