Configuration
testpilot-ai supports multiple configuration methods with a clear priority order.
Priority Order
CLI flags > Config file > package.json "autotest" field > Auto-detected framework > Defaults
Config File
Create autotest.config.json or .autotestrc in your project root:
{
"provider": "anthropic",
"model": "claude-sonnet-4-20250514",
"framework": "vitest",
"edgeCases": true,
"errorHandling": true,
"maxTokens": 4096,
"temperature": 0.2
}
Supported file names
autotest.config.json.autotestrc.autotestrc.json
package.json
Add an autotest field to your package.json:
{
"name": "my-project",
"autotest": {
"provider": "openai",
"model": "gpt-4o",
"framework": "vitest"
}
}
Framework Auto-Detection
testpilot-ai automatically detects your test framework from package.json:
- If
vitestis indevDependencies→ uses Vitest - If
jestor@jest/coreis indevDependencies→ uses Jest - If
mochais indevDependencies→ uses Mocha - If the
testscript containsvitest,jest,mocha, ornode --test→ uses that framework - Default → Vitest
When --verify is used, testpilot also preflights that the chosen framework is actually installed in your project (node_modules/<framework> exists). If not, it fails fast with a clear FrameworkNotInstalledError instead of hanging on an npx install prompt.
TypeScript Path Aliases
When the analyzer follows imports for context, it resolves both relative paths and tsconfig path aliases. Given a tsconfig.json like:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["src/*"],
"~lib/*": ["src/lib/*"]
}
}
}
…imports such as import { foo } from '@/lib/foo' are followed back into the project so the LLM has the relevant type definitions in context. External node_modules imports are still skipped.
Environment Variables
API keys are resolved from standard environment variables:
| Provider | Environment Variable |
|---|---|
| OpenAI | OPENAI_API_KEY |
| Anthropic | ANTHROPIC_API_KEY |
GOOGLE_API_KEY | |
| Ollama | None needed (local) |
All Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
provider | LLMProvider | "openai" | LLM provider — openai, anthropic, google, or ollama |
model | string | Provider default | Model name |
apiKey | string | From env var | API key |
framework | "vitest" | "jest" | "mocha" | "node" | Auto-detected | Test framework |
outDir | string | Same as source | Output directory |
overwrite | boolean | false | Overwrite existing tests |
edgeCases | boolean | true | Include edge case tests |
errorHandling | boolean | true | Include error handling tests |
instructions | string | — | Custom LLM instructions |
maxTokens | number | 4096 | Max LLM tokens |
temperature | number | 0.2 | LLM temperature |