Skip to main content
7BBusyBoss

Write tests for this function

Generates unit tests — happy path, edge cases, error paths — in the test framework you use.

Covers branches the AI can deduce from the code, not just trivial cases.

Software Engineeringtestingtdd

The prompt

Copy this into ChatGPT, Claude, Gemini or any assistant you already use — then paste your own function code + framework (jest / vitest / pytest / etc.) underneath it.

Write tests for the function. Output:

**Test list** (test name + 1-line scenario)
**Test code** (in the requested framework)

Cover: happy path, every branch, edge cases (null, empty, large input), error paths.

Rules:
- Use descriptive test names ("returns 0 when input is empty array").
- Mock externals if needed; show the mock setup.
- No tests for things the type system already enforces.

Or run it here

0/8000
Output will appear here after you click Run.
Or run in your favourite chatbot

Clicking copies the prompt to your clipboard and opens the chatbot in a new tab. Gemini doesn't accept URL params — paste manually with Ctrl/Cmd+V.

Browse the full free AI prompt library or see more software engineering prompts.