Skip to content

serializeForSnapshot

serializeForSnapshot(result, options?): Record<string, unknown>

Creates a deterministic serializable form of a RunResult for snapshot comparison.

Sorts state keys alphabetically, excludes specified keys, and produces a plain object suitable for Vitest’s built-in snapshot matching.

Pick<RunResult, "text" | "state"> & object

The run result (or any object with text, state, data)

SnapshotOptions

Optional exclusion list for state keys

Record<string, unknown>

Deterministic plain object