
Unit Test Generator
Generate production-ready unit tests across Jest, Vitest, Pytest, and Go
What You Can Do
This skill analyzes your functions and classes to generate exhaustive unit tests that maximize coverage and catch regressions. It systematically identifies logical branches, input variations, and failure modes—then produces framework-specific test code with proper setup/teardown and mocks. Your tests are immediately runnable with clear assertions and meaningful error messages.
Features
Generates tests for Jest, Vitest, Pytest, and Go testing with correct syntax and idioms
Identifies and tests all logical paths, conditionals, and error handling routes
Automatically covers boundary values, null/undefined inputs, type mismatches, and unusual states
Creates appropriate fixtures, mocks, and setup/teardown code for each test
Generates tests for exception handling, timeout scenarios, and failure states
Output serves as executable specifications showing expected function behavior
Analyzes code regardless of language; produces framework-specific output
Example Output
Input function:
function calculateDiscount(price, customerType, quantity) {
if (price <= 0) throw new Error('Invalid price');
let discount = 0;
if (customerType === 'premium') discount = 0.2;
else if (customerType === 'member') discount = 0.1;
if (quantity >= 10) discount += 0.05;
return price * (1 - discount);
}
Generated Jest tests:
describe('calculateDiscount', () => {
it('returns full price for regular customer with small quantity', () => {
expect(calculateDiscount(100, 'regular', 1)).toBe(100);
});
it('applies premium discount of 20%', () => {
expect(calculateDiscount(100, 'premium', 1)).toBe(80);
});
it('applies member discount plus bulk bonus', () => {
expect(calculateDiscount(100, 'member', 10)).toBe(85);
});
it('throws error for negative price', () => {
expect(() => calculateDiscount(-50, 'regular', 1)).toThrow('Invalid price');
});
it('throws error for zero price', () => {
expect(() => calculateDiscount(0, 'premium', 5)).toThrow('Invalid price');
});
});
What's Included
- SKILL.md: Complete instruction file with overview, usage guidelines, and framework-specific prompts
- Test template library: Pre-formatted test stubs for Jest, Vitest, Pytest, and Go testing
- Branch analysis checklist: Systematic guide for identifying edge cases and boundary conditions
- Mock/fixture patterns: Common setup patterns for different frameworks and dependency types
- Framework quick-reference: Syntax examples and assertion methods for each supported framework
Who It's For
- QA Engineers — Generate comprehensive test suites to verify code quality and catch regressions
- Full-stack developers — Create unit tests for new features before or after implementation
- Backend/API developers — Test functions, controllers, and service methods across Python, Go, and Node.js
- Frontend developers — Generate tests for utility functions, hooks, and component logic using Jest/Vitest
- Tech leads and code reviewers — Use generated tests as baselines for coverage analysis and test design review
Best For
- New function/class testing — Immediately generate tests when writing new code
- Refactoring coverage — Create comprehensive tests before modifying existing functions
- Edge case discovery — Systematically identify and test boundary conditions and error paths
- Test coverage gaps — Fill uncovered branches with targeted edge case tests
- Code documentation — Use generated tests as executable specifications of expected behavior







