arrow_back
Prompt Utopia Prompt Utopia
Automated Unit & Integration Test Suite Generator for Web Apps

Automated Unit & Integration Test Suite Generator for Web Apps

Generates a comprehensive unit and integration test suite for any web app code, covering happy paths, edge cases, error handling and component tests.

integration tests Jest MVP pytest QA TDD testing unit tests

Prompt Template

You are a senior QA engineer and test automation expert specialized in web applications.

Generate a comprehensive test suite for the following code/feature:

- Framework/language: {framework} (e.g., React/Jest, Node.js/Jest, Python/pytest, Django/pytest)
- What to test: {what_to_test} (e.g., "user authentication API", "shopping cart React component", "database queries", "payment webhook handler")
- Testing library: {testing_library} (e.g., Jest + React Testing Library, Vitest, pytest, Mocha + Chai)
- Code to test (paste your code here):

```
{code_to_test}
```

Generate a complete, production-ready test suite covering:

## Unit Tests
Write thorough unit tests that cover:
1. **Happy path** — All expected normal use cases
2. **Edge cases** — Empty inputs, boundary values, maximum limits
3. **Error cases** — Invalid inputs, missing required fields, type mismatches
4. **Null/undefined handling** — What happens with missing data

## Integration Tests (if applicable)
5. **API endpoint tests** — Test full request/response cycle with supertest or httpx
6. **Database interaction tests** — Test actual DB operations with a test database or mocks
7. **Authentication tests** — Test protected routes with and without valid tokens

## Component Tests (if frontend)
8. **Render tests** — Component renders without crashing
9. **User interaction tests** — Simulate clicks, typing, form submission
10. **Async behavior** — Loading states, error states, success states

## Test Configuration
11. **jest.config.js / pytest.ini** — Test configuration file
12. **Test setup file** — Global mocks, test database setup/teardown
13. **Mock files** — Mock external services (email, Stripe, S3, etc.)
14. **package.json test scripts** — test, test:watch, test:coverage commands

Requirements:
- Aim for >80% code coverage
- Use descriptive test names (Given/When/Then pattern)
- Group tests with describe blocks
- Add comments explaining the purpose of non-obvious tests
- All tests must be independent and not share state

Output all test files with their paths clearly labeled.

How to use this prompt

  1. 1 Click Copy Prompt above to copy the template to your clipboard.
  2. 2 Paste it into ChatGPT, Claude, Gemini or any AI tool of your choice.
  3. 3 Replace any {variables} in curly braces with your specific details.