Introduction
testpilot-ai is an AI-powered test generation tool for JavaScript and TypeScript that actually works. It generates tests, runs them, and auto-fixes failures in a loop until they pass.
Why testpilot-ai?
| testpilot-ai | Writing tests manually | Copilot suggestions | |
|---|---|---|---|
| Speed | Entire test file in seconds | Hours per file | One test at a time |
| Coverage | Edge cases + error handling | Often forgotten | Inconsistent |
| Framework-aware | Vitest & Jest native | Manual setup | Generic |
| Multi-provider | OpenAI, Anthropic, Google, Ollama | — | OpenAI only |
| AST-based analysis | Understands your code structure | — | Context-window limited |
Key Features
- TypeScript AST analysis — Uses the TypeScript compiler API to parse your code, extracting exported functions, classes, parameters, types, JSDoc, and imports
- Multi-provider LLM support — Works with OpenAI, Anthropic, Google, and Ollama (local models) via aiclientjs
- Framework-aware — Generates native Vitest or Jest tests with auto-detection from
package.json - Streaming output — Real-time LLM output in the terminal
- Smart configuration — CLI flags, config files, and
package.jsonwith sensible defaults - Clean CLI — Beautiful terminal output with progress and summaries
Quick Example
npx testpilot src/utils.ts --provider openai
This will:
- Analyze
src/utils.tsusing the TypeScript compiler API - Build a rich prompt with full type information
- Send it to the LLM and stream the output
- Write a
src/utils.test.tsfile with comprehensive tests