Fastest Way to Get Started: Use This creates everything you need: package.json, test files, Vitest config, GitHub Actions workflow, and prompts for your API key. Then just run
testdriverai init to scaffold a complete project automatically:npm test!For manual setup, continue with the steps below.Prerequisites
Node.js
Node.js 18 or higher
Package Manager
npm, yarn, or pnpm
Step 1: Install TestDriver
Install TestDriver and Vitest test runner:Step 2: Get Your API Key
1
Sign up
Visit console.testdriver.ai and create a free account.
2
Generate API Key
Navigate to Settings → API Keys and generate a new key.The key will look like:
tdai-1234567890abcdef1234567890abcdef3
Save API Key
Create a
.env file in your project root:.env
Step 3: Create Your First Test
Create a test filetest.test.js:
test.test.js
That’s it! TestDriver automatically handles authentication, browser launch, navigation, video recording, and cleanup.
Step 4: Run Your Test
Run your test with Vitest:Optional: Configure Vitest
For a better experience, create avitest.config.mjs:
vitest.config.mjs
Installation Options
TypeScript Setup
TestDriver includes TypeScript definitions out of the box:test.test.ts
Global Installation (Optional)
Install TestDriver CLI globally for project scaffolding and sandbox management:Monorepo Setup
For monorepos, install TestDriver in the root and reference it from test packages:package.json (root)
packages/app/package.json
Alternative Test Frameworks
While we recommend Vitest, TestDriver works with any test framework:- Vitest (Recommended)
- Jest
- Mocha
- Node (No Framework)
Verify Installation
Run this quick verification to ensure everything is set up correctly:verify.test.js
Troubleshooting
API Key Not Found
API Key Not Found
Error:
TestDriver API key not foundSolutions:- Check
.envfile exists in project root - Verify key format:
TD_API_KEY=tdai-... - Restart your terminal/IDE to reload environment
- Or pass API key directly:
Module Not Found
Module Not Found
Error:
Cannot find module 'testdriverai'Solutions:- Ensure you’re in the correct directory
- Run
npm installagain - Check
package.jsonincludes testdriverai - Delete
node_modulesand reinstall:
Test Timeout
Test Timeout
Error: TestDriver tests can take longer than unit tests due to AI analysis and browser automation.
Test timed out after 5000msSolution: Increase timeout in vitest config:vitest.config.mjs
TypeScript Errors
TypeScript Errors
Error:
Cannot find type definitionsSolution: TestDriver includes types by default, but ensure your tsconfig.json is correct:tsconfig.json
Network/Firewall Issues
Network/Firewall Issues
Error: For on-premise deployment, see self-hosting guide.
Failed to connect to TestDriver APISolution:- Check your internet connection
- Verify firewall allows outbound HTTPS
- If behind corporate proxy, configure:
.env
Next Steps
Now that you have TestDriver installed:Write Your First Test
Learn how to write effective TestDriver tests
Generate Tests with AI
Use Claude to generate tests automatically
View Examples
See TestDriver in action with examples
API Reference
Explore all available methods

