Where to set options
Pass options in any of three places:vitest.config.mjs
- Options you pass to the hook or the constructor
- Plugin options in
vitest.config - Environment variables:
TD_OS,TD_API_ROOT, andTD_E2B_TEMPLATE_ID - Defaults
connect() override the client’s values for that connection only.
Sandbox
These options control the virtual machine that runs your test.'linux' | 'windows'
default:"linux"
The operating system of the sandbox. You can also set this with the
TD_OS environment variable.Enterprise 'windows' is available on Enterprise plans.string
default:"1366x768"
The screen resolution of the sandbox, such as
'1920x1080'.Enterprise Custom resolutions are available on Enterprise plans.boolean
default:"true"
Create a new sandbox for this run. Set to
false to reuse a recent sandbox when one is available. Defaults to false when you set sandboxId or reconnect.boolean
default:"false"
Reattach to the last sandbox this project used. The SDK records it in
.testdriver/last-sandbox on every successful connect.While reconnect is true, provision methods such as chrome() and installer() are skipped, because the app is already running. The sandbox must still be alive. See keepAlive and Reuse a sandbox while you iterate.string
Attach to a specific sandbox by its id, for example to pin a chain of tests to one machine. This sets
newSandbox to false.Unlike reconnect, sandboxId alone doesn’t skip provision calls. Set reconnect: true as well if the app is already running.number
default:"60000"
The number of milliseconds to keep the sandbox running after
disconnect(), so you can reconnect to the same sandbox for debugging. Values above 30 minutes are capped at 30 minutes, and 0 uses the default.boolean
default:"false"
Keep the sandbox running when a test fails, and print its id so you can reconnect with
sandboxId and debug. Available only in the Vitest hook.object
Extra
TD_* settings for the SDK itself, as key-value pairs. These configure TestDriver on your machine, not environment variables inside the sandbox. To set variables in the sandbox, run a command with exec().Example
Preview and recording
These options control what you see while the test runs.'browser' | 'ide' | 'none'
default:"browser"
The preview mode for live test visualization.
"browser"opens the debugger in your default browser."ide"opens the preview in an editor panel. This needs the TestDriver extension for VS Code or Cursor."none"runs without a visual preview. Use this in CI.
boolean
default:"false"
Deprecated. Use
preview: "none" instead. headless: true maps to preview: "none".boolean
default:"false"
Save a screenshot before and after each
testdriver method call and each find(), and when one fails, to .testdriver/screenshots/<test file>/. Actions on an element, like element.click(), aren’t captured. Files are named like 001-find-before-L42-submit-button.png. See Screenshots.boolean
default:"true"
Write SDK logs to the console. You can change this at runtime with
setLogging().boolean
default:"true"
Send usage analytics to TestDriver.
Example
AI and element location
These options control how the AI locates elements and checks assertions.boolean
default:"false"
Double-check every
find() result with a second AI call. Off by default, because it makes each call slower.When on, after the AI locates an element:- A second AI looks at that spot and confirms it’s the element you described.
- If it isn’t, TestDriver locates the element again with a hint about what was wrong, then checks once more.
- If that check also fails,
find()returns an element whosefound()isfalse.
find(description, { verify: true }). See find().object
Global AI sampling configuration. These values apply to
find() verification and to assert(). You can override them for one assert() call with its ai option. find() ignores a per-call ai option, so set it here.Example
Caching
These options control the element cache, which reuses element positions from a passing run when the screen hasn’t changed. See Caching.boolean | object
default:"true"
Pass
false to turn the cache off, or an object to set the match thresholds.cache: { enabled: false } does not turn the cache off. Use cache: false or TD_NO_CACHE=true.string
The key the cache is stored under. By default, the SDK uses a hash of the test file, so editing the file starts a fresh cache. Set your own key to keep the cache across edits, or to share it between files.
object
Deprecated. Use
cache.thresholds instead.Example
Redraw detection
These options make the SDK wait for the screen to settle after each action. Redraw detection is off by default. See Redraw.boolean | object
default:"false"
Turn on screen-change detection with
true, or pass an object to set the thresholds.number | object
Deprecated. Use
redraw instead.Example
Self-hosted and infrastructure
Most projects don’t need these. They’re for self-hosted or custom deployments.string
The API endpoint URL. The default depends on the release channel. You can also set this with the
TD_API_ROOT environment variable.string
The IP address of a running sandbox. The SDK connects to this address directly.Enterprise Connecting to your own machines is available on Enterprise plans.
string
A custom AMI id for the sandbox instance (AWS deployments). Example:
'ami-1234'.string
The EC2 instance type for the sandbox (AWS deployments). Example:
'i3.metal'.string
The E2B template id to use when the SDK creates the sandbox. You can also set this with the
TD_E2B_TEMPLATE_ID environment variable.
