Skip to content

toMatchLines

Assert that a region's lines match an expected array. Trailing whitespace is trimmed per line.

Signature

typescript
expect(region).toMatchLines(lines: string[], options?: { timeout?: number })

Parameters

ParameterTypeDescription
linesstring[]Expected lines to match
options.timeoutnumberAuto-retry timeout in ms (Playwright-style)

Usage

typescript
// Match full screen content
expect(term.screen).toMatchLines(["Line 1", "Line 2", "", "Line 4"])

// With auto-retry
await expect(term.screen).toMatchLines(["Ready", ""], { timeout: 5000 })

// Negation
expect(term.screen).not.toMatchLines(["old content"])

Accepts

RegionSupported
term.screenYes
term.scrollbackYes
term.row(n)Yes
term.range(r1, c1, r2, c2)Yes
term.cell(r, c)No

Notes

  • Trailing whitespace is trimmed per line before comparison
  • The number of lines must match exactly
  • Empty strings in the array match blank terminal lines

See Also