toMatchAgentSnapshot
toMatchAgentSnapshot(
this,received,options?):object
Vitest custom matcher that compares a RunResult against a stored snapshot.
Uses deterministic serialization (sorted state keys, excluded keys removed)
and delegates to Vitest’s built-in toMatchSnapshot() for the actual
snapshot file management.
Register with expect.extend({ toMatchAgentSnapshot }) and use as:
expect(result).toMatchAgentSnapshot({ exclude: ['observe:duration'] })Parameters
Section titled “Parameters”any
Vitest matcher context
received
Section titled “received”Pick<RunResult, "text" | "state"> & object
The RunResult to snapshot
options?
Section titled “options?”Optional snapshot options (exclude keys, etc.)
Returns
Section titled “Returns”object
Matcher result with pass/fail and message
message
Section titled “message”message: () =>
string
Returns
Section titled “Returns”string
pass:
boolean