Skip to content

toHaveBg

Deprecated

Prefer toHaveAttrs which checks multiple attributes at once:

typescript
expect(term.cell(0, 0)).toHaveAttrs({ bg: "#282a36" })

Assert that a cell has a specific background color. Accepts hex strings or RGB objects.

Signature

typescript
expect(cell).toHaveBg(color: string | RGB)

Parameters

ParameterTypeDescription
colorstring | RGBExpected color as "#rrggbb" or { r, g, b }

Usage

typescript
// Hex string
expect(term.cell(0, 0)).toHaveBg("#282a36")

// RGB object
expect(term.cell(0, 0)).toHaveBg({ r: 40, g: 42, b: 54 })

// Negation
expect(term.cell(0, 0)).not.toHaveBg("#ffffff")

Accepts

RegionSupported
term.cell(r, c)Yes
term.screenNo
term.row(n)No

Notes

  • Colors are resolved to RGB values by the backend
  • Palette colors (0-255) are resolved to their RGB equivalents
  • Default background color depends on the backend's theme

See Also