Skip to content

toMatchSvgSnapshot

Match an SVG screenshot of the terminal against a Vitest snapshot. Captures the full visual representation including colors and styling.

Signature

typescript
expect(term).toMatchSvgSnapshot(options?: { name?: string; theme?: SvgTheme })

Parameters

ParameterTypeDescription
options.namestringOptional snapshot name
options.themeSvgThemeSVG color theme to use

Usage

typescript
// Basic SVG snapshot
expect(term).toMatchSvgSnapshot()

// Named snapshot
expect(term).toMatchSvgSnapshot({ name: "rendered-ui" })

// With custom theme
expect(term).toMatchSvgSnapshot({ theme: myTheme })

Accepts

TargetSupported
term (TerminalReadable)Yes
term.screenNo
term.cell(r, c)No

Notes

  • Uses Vitest's built-in snapshot machinery
  • The SVG output includes colors, fonts, and styling information
  • Update snapshots with vitest --update
  • For text-only snapshots, use toMatchTerminalSnapshot

See Also