Write Unit Tests for an Existing Function
Generate a thorough unit test suite covering happy path, branches, edges, and errors.
§ The Prompt— ready to copy
write-unit-tests-from-code.prompt
Write unit tests for this function. Code: [PASTE CODE] Test framework: [VITEST/JEST/PYTEST/ETC]. Cover: (1) happy path, (2) all branch conditions, (3) edge cases (empty, null, max, boundary), (4) error cases. Use the AAA pattern (Arrange-Act-Assert). For each test, the name must describe the behavior in plain English. Add one comment for any test that needs context.
Replace anything in [BRACKETS] with your specifics before sending.
Best For — Roles
Use For — Tasks
§ Related Entries
You may also need
№ 022coding
Generate Unit Tests for a Function
Generate comprehensive unit tests with happy path, edge cases, and failure modes.
For
claude·chatgpt
№ 023coding
Write a Clear Git Commit Message
Generate a Conventional Commits-compliant git commit message with context and rationale.
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