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.
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.
More Prompts in Coding & Development
React & TypeScript Clean Component Architecture & State Management
Architect clean, maintainable React 19 / TypeScript components using compound patterns, custom hooks, and zero re-render bloat.
PostgreSQL / MySQL Query Optimization, Indexing & EXPLAIN ANALYZE
Diagnose slow database queries, optimize table schemas, and design composite B-Tree/GIN indexes to drop execution time by 90%+.
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.