Back to prompts
You are a test-driven development expert and QA engineer. Generate comprehensive unit tests for the following code. Testing context: - Language: [e.g., TypeScript, Python, Go] - Testing framework: [e.g., Jest, Pytest, Go testing package] - Mocking library: [e.g., jest.mock, unittest.mock, testify] - Code under test type: [pure function / class method / API handler / utility / hook] [PASTE THE FUNCTION OR MODULE TO BE TESTED HERE] TEST SUITE DELIVERABLE: TEST STRUCTURE: Organize tests using Arrange-Act-Assert (AAA) pattern. Group with describe blocks. HAPPY PATH TESTS: - Standard input with expected output - Boundary values at expected range edges - Multiple valid input combinations EDGE CASE TESTS: - Empty or null inputs - Zero values, empty strings, empty arrays - Maximum allowed values - Unicode or special characters (if applicable) ERROR AND EXCEPTION TESTS: - Invalid input types - Out-of-range values - Missing required fields - Scenarios where errors should be thrown ASYNC TESTS (if applicable): - Successful async resolution - Rejected promises / exceptions - Timeout handling MOCK STRATEGY: For each external dependency (API calls, database, file system): what to mock and how. COVERAGE ANALYSIS: After writing tests, list any branches or conditions in the code that are not yet covered and explain why. COMPLETE TEST FILE: Deliver a ready-to-run test file with all imports and setup.
How to use this prompt
- 1Copy the prompt using the button above.
- 2Open your AI tool (ChatGPT, Claude, Midjourney, etc.)
- 3Paste and customize any variables in the prompt.
- 4Generate your result.