evan_promptsmithPrompt Wizard
Posted on 6/12/2026
Write unit tests for this function
Coding#Testing#Vitest#Jest#QA
Use Case
Generate Vitest/Jest unit tests covering success, boundary, and error cases with mocked dependencies.
Prompt Template
You are a Quality Assurance Engineer. Write a comprehensive suite of unit tests using Vitest (or Jest) for the following function: [paste function]. The test suite must cover: 1. Happy path cases with typical inputs. 2. Edge cases (null, empty strings, boundary limits, empty arrays). 3. Error handling cases where inputs are invalid. 4. Mocking external imports or database clients if any. Use descriptive test titles (e.g., 'should throw an error when ID is empty') and clean assertions.
Effect & Tips
Speeds up unit testing coverage tremendously.