Skip to main content

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 vitest is in devDependencies → uses Vitest
  • If jest or @jest/core is in devDependencies → uses Jest
  • If mocha is in devDependencies → uses Mocha
  • If the test script contains vitest, jest, mocha, or node --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:

ProviderEnvironment Variable
OpenAIOPENAI_API_KEY
AnthropicANTHROPIC_API_KEY
GoogleGOOGLE_API_KEY
OllamaNone needed (local)

All Configuration Options

OptionTypeDefaultDescription
providerLLMProvider"openai"LLM provider — openai, anthropic, google, or ollama
modelstringProvider defaultModel name
apiKeystringFrom env varAPI key
framework"vitest" | "jest" | "mocha" | "node"Auto-detectedTest framework
outDirstringSame as sourceOutput directory
overwritebooleanfalseOverwrite existing tests
edgeCasesbooleantrueInclude edge case tests
errorHandlingbooleantrueInclude error handling tests
instructionsstringCustom LLM instructions
maxTokensnumber4096Max LLM tokens
temperaturenumber0.2LLM temperature