Skip to main content
This page lists every cache option, its default, and where you can set it. The cache is on by default, so you only need these to tune or turn it off. For how caching works and when it helps, see Speed up reruns with caching.

Client options

Pass these to TestDriver(context, options) or new TestDriver(options). They apply to every call the client makes.
boolean | object
default:"true"
Pass false to turn the cache off. Pass an object to change the match thresholds.
string
The key cache entries are stored under. By default, TestDriver generates one from the test file. See Cache keys.
object
Deprecated. Use cache.thresholds instead.

Per-call options

Override the client settings for a single call.

find()

string
Use this key for this call instead of the client’s key.
number
Overrides cache.thresholds.find.screen for this call.
number
Overrides cache.thresholds.find.element for this call.

findAll()

findAll() takes cacheKey and cache.thresholds.screen. It doesn’t use the element threshold.

assert()

string
Use this key for this call instead of the client’s key.
number
Overrides cache.thresholds.assert for this call.

Threshold priority

When a threshold is set in more than one place, the most specific wins:
  1. The per-call option, such as find(description, { cache: { thresholds: { screen: 0.1 } } })
  2. A legacy number argument, such as find(description, 0.1)
  3. The client option, cache.thresholds
  4. The defaults: screen 0.05, element 0.8, assert 0.05

Cache keys

Cache entries are stored under a key. By default, TestDriver generates the key from the test file:
  • It hashes the contents of the file that creates the client (SHA-256, first 16 hex characters).
  • Editing the file changes the hash, so the file starts with a fresh cache.
  • Each test file gets its own cache.
Set cacheKey to keep a cache across edits, or to share one between files that use the same screens:
If TestDriver can’t read the test file, it can’t generate a key. find() and findAll() then skip the cache unless you set cacheKey.

What must match

A cached entry is reused only when all of these match the run that created it:
  • The cache key.
  • The exact description passed to find(), or the exact assertion text.
  • The sandbox OS and screen resolution.
Entries become usable only after the test that created them passes.

Turn the cache off

Turn the cache off for one client:
Or for a whole run:
cache: { enabled: false } doesn’t turn the cache off. Use cache: false or TD_NO_CACHE=true.

Inspect a result

Read the cache details from the element that find() returns:
object
To browse or clear your team’s cached entries, open the Cache page in the TestDriver console.

Caching

How the cache works and when it helps.

Options

Every client option, with its default.

find()

Locate an element by describing it.

assert()

Check the screen with an AI assertion.