Setup
TestDriver integrates with AI coding assistants through the VS Code extension and MCP server. The same MCP server works with GitHub Copilot, Cursor, Claude Desktop, and any other MCP-capable assistant. This section walks you through the complete setup.Prerequisites
Before you begin, you’ll need:- An MCP-capable AI assistant — Such as GitHub Copilot, Cursor, or Claude Desktop. For Copilot, a free tier is available.
- TestDriver Account — Create a free account at console.testdriver.ai to get your API key. 60 free device minutes, no credit card required.
- VS Code — The TestDriver extension provides the best experience with live preview and integrated test running.
Setup Steps
1
Install the TestDriver Extension
Install TestDriver for VS Code
- One-click sign-in and project initialization
- Live preview panel for watching tests execute
- MCP server configuration
2
Sign Into TestDriver
Sign in to connect your account and API key.
- Open the command palette (
Cmd+Shift+PorCtrl+Shift+P) - Run TestDriver: Login
- Your browser will open to the TestDriver sign-in page
- Sign in (or create an account)
- You’ll be redirected back to VS Code, now signed in
3
Initialize Your Project
Set up TestDriver in your project with a single command.
- Open the command palette (
Cmd+Shift+PorCtrl+Shift+P) - Run TestDriver: Init Project
- Creates a
package.jsonwith TestDriver and Vitest dependencies - Generates a
vitest.config.mjswith proper timeout settings - Creates example test files in
tests/ - Sets up
.envwith your API key - Creates the TestDriver agent file at
.github/agents/testdriver.agent.md - Configures the MCP server
If you already have a
package.json, the command will add the necessary dependencies to it.4
Start the MCP Server
The MCP server enables your AI assistant to control TestDriver sandboxes.After initialization, the MCP configuration is created at To start the MCP server:
.vscode/mcp.json:.vscode/mcp.json
- Open the command palette (
Cmd+Shift+PorCtrl+Shift+P) - Run MCP: List Servers
- Click on the testdriver server
- Select Start Server
5
Install Vitest Extension (Recommended)
For the best experience running tests, install the Vitest extension:After installation, you’ll see a beaker icon in the sidebar for accessing the Test Explorer.
Vitest Extension
Run tests with GUI mode from the Test Explorer
Verify Your Setup
To verify everything is configured correctly:- Open the command palette and run TestDriver: Check Status
- You should see:
- ✅ Signed in
- ✅ MCP server configured
- ✅ Project initialized
The Agent File
During initialization, TestDriver creates an agent file at.github/agents/testdriver.agent.md. This file tells your AI assistant how to use TestDriver’s MCP tools.
The agent has access to tools like:
session_start— Launch a sandbox with Chrome or other appsfind/click/type— Interact with elements on screenassert— Verify conditions using AI visionscreenshot— Capture the current screen state
Configuring the Device
Provision methods are the starting point for most tests. They launch applications in your sandbox and prepare the environment for testing — a browser, a desktop app, a Chrome extension, or VS Code.Chrome Browser
The most common starting point for web testing. Launches Chrome browser and navigates to a URL.Options
Example: Basic Web Test
provision.chrome() automatically starts Dashcam recording and waits for Chrome to be ready before returning.Chrome Extensions
Launch Chrome with a custom extension loaded. Supports both local extensions and Chrome Web Store extensions.Load from Local Path
Clone or create an extension locally, then load it:Load from Chrome Web Store
Load any published extension by its Chrome Web Store ID:Options
Example: Testing a Chrome Extension
Desktop Apps
Download and install desktop applications. Supports.deb, .rpm, .msi, .exe, .AppImage, .dmg, .pkg, and shell scripts.
Options
Supported File Types
Example: Install and Test a Desktop App
Example: Windows Installer
Manual Installation
Setlaunch: false to download without auto-installing:
VS Code
Launch Visual Studio Code with optional workspace and extensions.Options
Example: VS Code Extension Test
Choosing the Right Provision Method
Configuring the Machine
TestDriver provisions a fresh cloud VM for every test by default. This section covers how to configure Linux and Windows machines, reduce startup time by keeping machines alive between runs, use provision scripts for repeatable setup, and install custom software on the fly.Linux Machines
Linux is the default operating system. No extra configuration is required.Common Linux Options
Windows Machines
Setos: "windows" to provision a Windows VM instead. Everything else works the same way.
Common Windows Options
Keeping Machines Alive Between Runs
Windows (and Linux) cold starts can be expensive if you’re iterating quickly. UsekeepAlive + reconnect to reuse the same VM across multiple test runs.
How it works
Every time the SDK successfully connects to a sandbox, it records the sandbox id in.testdriver/last-sandbox inside your project directory. The next test that opts in with reconnect: true reads that file and reattaches automatically — no manual id tracking required.
Provision calls (testdriver.provision.chrome(...), vscode(...), etc.) are skipped when reconnecting, because the application is already running inside the sandbox from the previous run.
.testdriver/last-sandbox is already covered by the default TestDriver .gitignore. Don’t commit it.Step 1 — Start the machine with a long keepAlive
Step 2 — Reattach automatically with reconnect: true
Step 2 (alternative) — Reattach to an explicit id
If you need to pin to a specific sandbox (CI matrix, multiple chains in parallel, etc.) pass the id directly:- You reuse a specific running machine directly
- You continue from the app state created in the earlier run
- You must run within the previous test’s
keepAlivewindow
Chaining describe blocks within one test file
A common pattern is to break a long flow into focuseddescribe blocks that share one sandbox — the first block provisions and signs in, later blocks reconnect and continue:
examples/reconnect-sequential.test.mjs.
How keepAlive works
keepAlive is a duration in milliseconds. After the SDK disconnects, the server keeps the VM running for that long before terminating it. The default is 60000 (1 minute). Note: keepAlive: 0 currently falls back to the default disconnect grace period rather than terminating immediately, so use a positive duration when you want to control the grace window explicitly.
Using Provision Scripts
Provision scripts let you run arbitrary setup steps before your test starts — downloading fixtures, seeding a database, configuring environment variables, and more. Usetestdriver.exec() to run shell or PowerShell commands directly in the sandbox.
exec() Reference
Full reference for running shell and PowerShell commands in the sandbox.
Linux setup script
Windows setup script (PowerShell)
Clone a repo and run a script
Installing Custom Software
You can install software at the start of a test usingexec(). This works for any package available via apt, brew, choco, winget, npm, pip, or direct download.
Linux — apt packages
Linux — Node.js tools
Windows — winget
Windows — Chocolatey
Download and run an installer
Installing software at test start adds to your test duration. For software you use in every test, consider preloading it into a custom VM image via the Enterprise self-hosted plan.
Want Software Pre-Installed on Every Machine?
Installing packages at runtime works well for occasional or lightweight dependencies. But if you’re installing the same 5-minute setup on every test run, you’re wasting time and credits. With the Self-Hosted Enterprise plan you get access to our golden VM base image and Packer scripts, so you can bake your applications, dependencies, and configuration directly into a custom AMI. Tests spin up with everything already installed — zero setup time.Self-Hosted Enterprise
Preload software, configure custom hardware, and run unlimited tests with a flat license fee. Our team assists with deployment and setup.
Running Tests
After creating tests with the TestDriver agent, you can re-run them without starting a new MCP session. Tests are saved as standard Vitest files that run independently — the same way on your machine and in CI.Running from Terminal
TestDriver works with Vitest’s test runner. Use Vitest to run your tests from the command line to see full output:Install Vitest globally for best results:
npm install vitest -g*.test.js, *.test.mjs, or *.spec.js.
Common CLI options
Coverage requires the
@vitest/coverage-v8 package. Install it with npm install -D @vitest/coverage-v8.Vitest UI
For interactive debugging, launch the web-based UI (starts in watch mode):Running from VS Code (GUI Mode)
For a visual testing experience, use the Vitest extension:1
Open Test Explorer
Click the beaker icon in the VS Code sidebar to open the Test Explorer. This shows all your test files and test cases.
2
Run Tests
Click the play button next to any test file or individual test to run it. You can also:
- Run all tests with the “Run All” button
- Debug tests with the “Debug” button
3
View Results
Test results appear inline:
- ✅ Green checkmark for passing tests
- ❌ Red X for failing tests
- Click on a failing test to see error details
Test Configuration
Timeouts
TestDriver tests require longer timeouts than typical unit tests. Yourvitest.config.mjs should have:
vitest.config.mjs
Environment Variables
Tests use theTD_API_KEY environment variable. Set it in your .env file:
.env
Parallel Execution
TestDriver runs each test in its own cloud sandbox, enabling true parallel execution. Run your entire test suite in minutes instead of hours. Your TestDriver plan includes a set number of license slots that determine how many tests can run simultaneously. Each running test occupies one slot — when the test completes and the sandbox is destroyed, the slot is immediately freed for the next test. SetmaxConcurrency in your Vitest config to match your license slot limit:
vitest.config.mjs
View your available slots at console.testdriver.ai. Upgrade anytime to increase parallelization.
Viewing Test Reports
After each test run, TestDriver provides a link to the full test report:- Video recording of the test
- Screenshots at each step
- Network logs and performance metrics
- Console output and errors
View Test Reports
Access all your test runs and recordings in the TestDriver console
Iterating on Tests
When tests fail or need updates, you have two options:Option 1: Ask the AI Assistant (Recommended)
For discovering updated element descriptions or debugging failures, chat with the TestDriver agent through your AI assistant:- Start a new session
- Navigate to the page
- Analyze the current state
- Update the test code
- Element text or layout has changed
- You need to see what’s currently on screen
- The failure reason isn’t obvious from the error message
Option 2: Edit the Code Directly
For simple changes, edit the test files directly:- Updating text strings
- Adjusting timeouts
- Fixing typos
Next
Validate
Now that your tests run anywhere, learn how to make strong assertions that catch real bugs.

