- Starts its own cloud sandbox.
- Runs its steps.
- Prints a link to a full report with a recording of the run.
Before you begin
- A project with TestDriver installed, with your API key in
.envasTD_API_KEY. See Set up a project. - At least one test, which you can generate with AI or write by hand.
Run tests from the terminal
Run every test in the project:.test or .spec plus a JavaScript or TypeScript extension, such as tests/login.test.mjs.
To run part of your suite, pass files, folders, or a name filter:
npx vitest (without run) for watch mode. It reruns tests when you save a file.
Run tests from VS Code
Install the Vitest extension to run tests from the Testing view. Click the run button next to a file or test. The result appears inline next to the code. To watch the sandbox in a panel beside your code, install the TestDriver extension and use theide preview mode below.
Watch a test run
TestDriver shows each run live. Choose where with thepreview option or the TD_PREVIEW environment variable:
Open the test report
When a test finishes, TestDriver prints a link to its report:Run tests in parallel
Vitest runs test files in parallel, and each running test gets its own sandbox. Your plan sets how many sandboxes can run at once. At the limit, a new test waits for a free slot instead of failing. By default, the SDK retries every 10 seconds for up to 60 seconds. SetTD_CONCURRENCY_MAX_WAIT (in seconds) to wait longer, or to 0 to fail immediately.
To cap how many test files run at once on your machine, limit Vitest’s workers:
Reuse a sandbox while you iterate
Each test normally starts a fresh sandbox, which takes time to boot, especially on Windows. While you work on a long flow, keep the sandbox running between runs and reconnect to it. Then you only rerun the steps you’re changing.-
Run the steps that already work with a longer
keepAlive. It keeps the sandbox running for that many milliseconds after the test ends (60 seconds by default, up to 30 minutes):tests/setup-cart.test.mjs -
In the file you’re working on, set
reconnect: true. TestDriver reattaches to the last sandbox it used, recorded in.testdriver/last-sandbox. It skipsprovisioncalls because the app is already open:tests/checkout.test.mjs
keepAlive window. Reconnecting fails if the sandbox has already shut down.
To connect to a specific sandbox instead, or for more sandbox options, see Customize devices.
Fix a failing test
When the app changes and a test no longer matches it, ask the TestDriver agent to update the test. It reruns the flow in a sandbox and sees the current screen:find() description or assertion, edit the test file directly.
To dig into what went wrong in a run, see Debug with screenshots.
Troubleshooting
Tests fail with a Vitest timeout
Tests fail with a Vitest timeout
Tests that drive a real machine take longer than Vitest’s 5-second default. Set
testTimeout and hookTimeout in vitest.config.mjs.npx testdriverai init sets both to 5 minutes:vitest.config.mjs
TestDriver can't find my API key
TestDriver can't find my API key
The SDK reads
TD_API_KEY from the environment. It loads .env in your project root automatically.Check that .env contains TD_API_KEY=..., or set the variable for one run:Tests wait a long time before starting
Tests wait a long time before starting
You’re probably at your plan’s sandbox limit, and tests are waiting for a free slot.Run fewer files at once with
--maxWorkers, or check your plan in the TestDriver console.Next steps
Make assertions
Write checks that catch the regressions you care about.
Debug with screenshots
See what the sandbox showed at each step of a run.
Run in CI/CD
Run your tests on every push and pull request.
Launch apps
Start Chrome, extensions, VS Code, or desktop apps in the sandbox.

