getEmitter() and listen with on():
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 thelogging 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 insideai(). Commands you call yourself, such as testdriver.click(), don’t emit them.
commandis the command name, anddatais the full command the AI generated.erroris the error message as a string.timinganddurationare in milliseconds.
Other events
The event list also contains names that Vitest tests don’t emit:
step:*,test:*, andfile:*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, andvm:showaren’t currently emitted.
Related
- getEmitter(): get the client’s emitter
- Redraw: what the redraw events measure
- Errors: the errors TestDriver throws
- Debug a failing test: find out why a test failed

