Skip to main content
TestDriver reports what it’s doing through an event emitter. Get it with getEmitter() and listen with on():
The emitter is an EventEmitter2 instance. Event names are segments separated by colons, such as redraw:complete.

Listen in a test

The emitter exists as soon as you create the client, so add listeners before the first command:
tests/login.test.mjs

Use wildcards

* matches one segment. ** matches any number of segments. Use a function listener, not an arrow function, to read the event’s name from this.event:
log:* matches log:log and log:warn but not log:markdown:start, which has three segments. Use log:** to match all of them.

Log events

The SDK prints these to the console unless you turn logging off with the logging option. There’s no log:info or log:error in the event list. Listen to log:log and error:* instead.

Error events

Sandbox events

Action events

Redraw events

Emitted only when redraw detection is on.
object
object

API request events

ai() command events

These fire for the commands the AI runs inside ai(). Commands you call yourself, such as testdriver.click(), don’t emit them.
  • command is the command name, and data is the full command the AI generated.
  • error is the error message as a string.
  • timing and duration are in milliseconds.

Other events

The event list also contains names that Vitest tests don’t emit:
  • step:*, test:*, and file:* come from running YAML test files.
  • command:stop, command:location, sandbox:error, sandbox:disconnected, sdk:error, sdk:progress, status, mouse-move, terminal:stdout, terminal:stderr, matches:show, and vm:show aren’t currently emitted.