Skip to main content

Overview

You configure the SDK with an options object. You can pass the object in three places:
The hook merges the options in this order. A later source replaces an earlier source:
  1. Default values
  2. Environment variables (TD_OS, TD_API_ROOT, TD_E2B_TEMPLATE_ID)
  3. Global plugin options
  4. Options that you pass to the hook or the constructor
Options that you pass to connect() replace the constructor 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.
string
default:"1366x768"
The screen resolution of the sandbox. Example: '1920x1080'. Custom resolutions are available only 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.
boolean
default:"false"
Reattach to the last used sandbox. The SDK reads the sandbox id from .testdriver/last-sandbox. The SDK writes this file on every successful connect.When reconnect is true, the SDK skips provision methods (chrome, vscode, installer, and others). The application is already running. The previous sandbox must still be alive. See keepAlive and the Run guide.
string
Reattach to a specific sandbox id. Use this for CI matrices or to pin a chain of tests to a known VM. This option implies reconnect: true. The SDK skips provision calls.
number
default:"60000"
The number of milliseconds to keep the sandbox alive after disconnect(). Set to 0 to end the sandbox at once. A longer value lets you reconnect to the same sandbox for debugging.
boolean
default:"false"
Keep the sandbox alive when a test fails. The SDK prints the sandbox id to the console. You can then reconnect with sandboxId and debug the failure. This option is available only in the Vitest hook.
object
Additional environment variables to pass to the sandbox.

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 the IDE panel. This mode 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:"true"
Record a Dashcam video of the test. See Dashcam.
boolean
default:"false"
Capture a screenshot before and after each command. The SDK saves the screenshots to .testdriver/screenshots/<test>/.The file name format is <seq>-<action>-<phase>-L<line>-<description>.png. Example: 001-click-before-L42-submit-button.png. See Debugging with 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"
Run a second AI check on every find() result. The check confirms that the coordinates match the requested element. This catches incorrect positions. It adds latency to each call.You can replace this value for one call with find(description, { verify: true }). See find.
object
Global AI sampling configuration. These values apply to find() verification and to assert(). You can replace them for one call with the ai option on that call.

Example

Caching

These options control the element cache. The cache stores the position of an element after the first find(). Later runs reuse the position when the screen has not changed. See Caching.
boolean | object
default:"true"
Enable or disable the cache. Pass an object to set the match thresholds.
string
The cache key for element location. When you set a key, the SDK ties the cache to that key. Use a different key for each test to keep the caches separate.
object
Deprecated. Use cache.thresholds instead.

Example

Redraw detection

These options control how the SDK waits for the screen to settle after an action. See Redraw.
boolean | object
default:"true"
Enable or disable screen-change detection. Pass an object to set the thresholds.
number | object
Deprecated. Use redraw instead.

Example

Self-hosted and infrastructure

Most users do not need these options. Use them 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.
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.

Quick reference