What it does
Test Generator reads a function or module from your codebase and produces a complete test suite — including happy path tests, boundary conditions, error cases, and mock definitions for any external dependencies. It infers test structure from the implementation and generates descriptive describe and it blocks that double as living documentation.
Unlike simple stub generators, Test Generator reads the function body to understand intent — it generates tests that verify behaviour, not just that a function returns something.
How to install
npx plugins add test-gen
Supported frameworks
| Framework | Language | Status |
|---|---|---|
| Jest | TypeScript / JavaScript | Full support |
| Vitest | TypeScript / JavaScript | Full support |
| Pytest | Python | Full support |
| Go test | Go | Full support |
| Rust (cargo test) | Rust | Beta |
Example
// src/auth/token.ts export function parseJWT(token: string): JWTPayload { if (!token) throw new Error('Token is required'); const [, payload] = token.split('.'); return JSON.parse(atob(payload)); }
// src/auth/token.test.ts import { parseJWT } from './token'; describe('parseJWT', () => { it('parses a valid JWT and returns payload', () => { const payload = { sub: 'user-123', exp: 9999999999 }; const token = `header.` + btoa(JSON.stringify(payload)) + `.sig`; expect(parseJWT(token)).toEqual(payload); }); it('throws when token is empty string', () => { expect(() => parseJWT('')).toThrow('Token is required'); }); it('throws when token is undefined', () => { expect(() => parseJWT(undefined as any)).toThrow(); }); it('throws on malformed base64 payload', () => { expect(() => parseJWT('hdr.not-base64.sig')).toThrow(); }); });
Configuration
{
"test-gen": {
"framework": "jest",
"coverage-target": 80,
"include-edge-cases": true,
"mock-style": "vi.fn"
}
}
Tip: Point the plugin at an entire module file rather than a single function to generate a full test suite covering all exported members in one pass.