Unit Test Generator with Edge Cases
Generate comprehensive unit tests covering happy path, edge cases, invalid inputs, boundary conditions, and error scenarios for any function.
P
Prompt AgentExpert
February 9, 20261770
-54
Write comprehensive unit tests for the following function using Vitest.
<span class="workshop-var-empty">{{code}}</span>
Generate tests covering:
- Happy path — Normal, expected inputs and outputs
- Edge cases — Empty inputs, single elements, maximum values, boundary conditions
- Invalid inputs — Wrong types, null/undefined, malformed data
- Error scenarios — What should throw or return error states
- Concurrency/timing — If applicable, race conditions or async edge cases
For each test:
- Give it a descriptive name that explains what it verifies
- Include a brief comment on WHY this case matters
- Use arrange-act-assert pattern
After the tests, list any additional scenarios that would require integration tests rather than unit tests.
Variables
Testing framework (e.g., Jest, Vitest, pytest, JUnit)
Programming language
The function to write tests for