Independent directory — not affiliated with Anthropic. Learn more

Test Generator

Development — Testing

Creates unit tests, integration tests, and edge cases from function signatures. Supports Jest, Vitest, Pytest, Go testing, and JUnit. Infers test cases from implementation logic so your coverage gaps close automatically.

987+ downloads
4.8 rating
by community
Updated May 2026
Testing Jest Pytest TDD Unit Tests

What it does

Test Generator reads a function or module and produces a complete, runnable test suite. It analyses the signature, return types, and implementation logic to derive meaningful test cases — not just trivial happy-path assertions. The output covers expected behavior, boundary conditions, null and undefined inputs, type coercion edge cases, and async error handling where applicable.

The skill understands TDD and BDD naming conventions. Generated tests follow your chosen framework's idioms: describe/it blocks for Jest and Vitest, def test_ fixtures for Pytest, table-driven subtests for Go, and parameterized JUnit 5 tests for Java. Each test includes a one-line comment explaining the case being verified.

How to install

bash
npx skills add user/test-generator

How to use

Paste the function you want tested, specify the framework, and ask for tests:

prompt
# Jest · TypeScript
Generate tests for this function:

function calculateDiscount(price: number, code: string): number {
  if (!code) return price;
  if (code === 'SAVE10') return price * 0.9;
  if (code === 'HALF') return price * 0.5;
  throw new Error('Invalid code');
}

The skill generates a full Jest test file:

typescript
import { calculateDiscount } from './discount';

describe('calculateDiscount', () => {
  // No code — returns full price
  it('returns original price when code is empty', () => {
    expect(calculateDiscount(100, '')).toBe(100);
  });

  // Valid SAVE10 — 10% off
  it('applies 10% discount for SAVE10', () => {
    expect(calculateDiscount(200, 'SAVE10')).toBe(180);
  });

  // Valid HALF — 50% off
  it('applies 50% discount for HALF', () => {
    expect(calculateDiscount(80, 'HALF')).toBe(40);
  });

  // Invalid code — throws
  it('throws Error for unknown discount code', () => {
    expect(() => calculateDiscount(100, 'BOGUS')).toThrow('Invalid code');
  });
});

Tip: For best edge-case coverage, include your TypeScript types or Python type hints. The skill uses type information to generate boundary tests for numeric ranges, empty collections, and null vs undefined distinctions automatically.

Supported frameworks

  • Jest & Vitest — TypeScript/JavaScript, mock factories, async/await
  • Pytest — fixtures, parametrize decorator, monkeypatching
  • Go testing — table-driven subtests, t.Run, benchmarks
  • JUnit 5 — parameterized tests, nested classes, assertions API