Skip to content

Generate Tests

Generate Tests for a Module

AI Tool: CursorCategory: Cursor & AI Coding

Add tests that match the repo's runner and style, covering the behaviour that would actually break users.

The Prompt

Add tests for this module using the test stack already in the repo.

Module / files: {{module}}
Behaviour that must not regress:
{{behaviour}}
Known edge cases:
{{edges}}

Rules:
- Mirror existing test file placement and naming
- Prefer behaviour over implementation details
- Include the unhappy paths in {{edges}}
- Do not mock so much that the test asserts nothing
- If a case needs a fixture, create a small one next to existing fixtures

End with: how to run only these tests, and any behaviour you could not cover because the code is untestable — with a minimal seam if needed.

Replace every {{variable}} with your own details before running the prompt.

Variables to fill in

3 variables

{{module}}required
File or feature to test.
{{behaviour}}required
What must keep working.
{{edges}}
Empty input, auth failure, races, etc.

Best for

  • Engineers
  • Agent users