Generate Unit Tests for a Function
Generate comprehensive unit tests with happy path, edge cases, and failure modes.
§ The Prompt— ready to copy
unit-test-generator.prompt
You are a test-driven development expert. Write comprehensive unit tests for the function below using [TEST FRAMEWORK: e.g. Jest / pytest / JUnit]. Cover: (1) the happy path, (2) edge cases (empty inputs, boundary values, null/undefined), (3) expected failure modes. Each test should have a descriptive name that reads like a sentence. Mock any external dependencies. FUNCTION: [PASTE FUNCTION]
Replace anything in [BRACKETS] with your specifics before sending.
Best For — Roles
Use For — Tasks
§ Related Entries
You may also need
№ 023coding
Write a Clear Git Commit Message
Generate a Conventional Commits-compliant git commit message with context and rationale.
For
claude·chatgpt
№ 099coding
Write Unit Tests for an Existing Function
Generate a thorough unit test suite covering happy path, branches, edges, and errors.
For
claude·chatgpt
№ 002coding
Perform a Thorough Code Review on a Pull Request
Get a senior-engineer-style code review with categorized, file-referenced feedback.
For
claude·chatgpt
№ 021coding
Refactor Code for Readability and Maintainability
Refactor any code for readability and maintainability without changing its behavior.
For
claude·chatgpt