Write Unit Tests — Cover Edge Cases
Generates unit tests in {{framework}} that cover the happy path, edge cases, and error conditions. Tests are runnable, not pseudocode.
coding
testingunit-teststdd
The prompt
Write unit tests for this function using {{test_framework}} (e.g., Jest, Vitest, pytest).
Cover these cases explicitly:
1. Happy path: typical valid input, expected output.
2. Edge cases: empty input, single element, very large input, boundary values.
3. Error cases: invalid input, null/undefined, wrong types — what the function should do (throw, return null, etc.).
4. Off-by-one risks: anything involving array indices, ranges, dates.
Each test must be runnable as-is. No "// TODO" placeholders. No mocking the function under test. Mock only external dependencies (network, time, randomness).
Code to test:
{{code}}
Recommended models
35 upvotes · 0 views · Coding