Coding & Development Intermediate Audience: Full-Stack Developers, QA Engineers, Tech Leads

Automated Unit & Integration Test Suite Generator (Vitest / Jest)

Generate bulletproof test suites covering happy paths, edge cases, error boundaries, and mock dependencies with 95%+ coverage.

#testing#unit-tests#vitest#jest#mocking

System Directive • Copy and Paste Below

Act as a senior Software Quality Engineer and automated testing lead.

Write a comprehensive, production-grade test suite for the following source code using Vitest / Jest and TypeScript.

### CODE UNDER TEST:
```typescript
[PASTE_SOURCE_CODE_FUNCTION_OR_CLASS_HERE]
```

### TESTING ENVIRONMENT:
- Test Runner: [VITEST_OR_JEST]
- Mocking Libraries Used: [MOCKING_PREFERENCES_E_G_MSW_VI_FN_JEST_MOCK]
- Target Code Coverage: 95%+ (Branches, Statements, Functions)

### DELIVERABLES:
1. **Test Suite Structure & Setup**:
   - Clean `describe` blocks grouping tests by function or method.
   - Proper `beforeEach` and `afterEach` cleanup to ensure complete test isolation (no shared mutable state).
2. **Happy Path Tests**:
   - Validating expected outputs given standard valid inputs.
3. **Edge Case Tests**:
   - Null / undefined / empty string handling.
   - Numerical boundary conditions (zero, negative, max integer).
   - Array bounds (empty list, single item, large 10,000+ item list).
4. **Error & Failure Boundary Tests**:
   - Simulating network timeouts, database connection drops, and HTTP 500 responses.
   - Verifying that custom errors are thrown with the expected error message and status code.
5. **Mock Implementations**:
   - Clean, typed mock implementations of external API calls, database queries, or file system access.

Customization & Placeholders

Paste your function or class. The generated test file covers happy paths, edge cases, and mocked network failures.

Example Input Values

Function: Async user subscription checkout validator verifying Stripe balance, user authorization, and database lock.

Expected Output Structure

Complete TypeScript Vitest file with MSW network mocks, boundary validation, and zero flaky tests.

Hardened Software Engineering by Qubenix

Qubenix builds mission-critical business software with automated test pipelines, static analysis, and zero downtime.

Explore Software Systems

More Prompts in Coding & Development

Coding & Development Intermediate

React & TypeScript Clean Component Architecture & State Management

Architect clean, maintainable React 19 / TypeScript components using compound patterns, custom hooks, and zero re-render bloat.

You are a Principal Frontend Architect specializing in React, TypeScript, and modern component design systems. Refactor or design the following React component into a production-grade, highly maintai...
#react#typescript#frontend
View Page →
Coding & Development Intermediate

Enterprise REST & GraphQL API Schema Designer with OpenAPI Specs

Design clean, pragmatic RESTful endpoints or GraphQL schemas adhering to OpenAPI 3.1 standards, pagination, and status codes.

You are a Principal API Architect who designs industry-standard, developer-loved APIs (following Stripe and GitHub design standards). Design a robust, comprehensive API specification for our applicat...
#api-design#rest#graphql
View Page →