Skip to content

toHaveCursorAt

Deprecated

Prefer toHaveCursor which checks multiple cursor properties at once:

typescript
expect(term).toHaveCursor({ x: 5, y: 2 })

Assert that the terminal cursor is at the given column and row.

Signature

typescript
expect(term).toHaveCursorAt(x: number, y: number, options?: { timeout?: number })

Parameters

ParameterTypeDescription
xnumberColumn (0-based)
ynumberRow (0-based)
options.timeoutnumberAuto-retry timeout in ms (Playwright-style)

Usage

typescript
// Top-left corner
expect(term).toHaveCursorAt(0, 0)

// Column 5, row 2
expect(term).toHaveCursorAt(5, 2)

// With auto-retry
await expect(term).toHaveCursorAt(0, 1, { timeout: 5000 })

// Negation
expect(term).not.toHaveCursorAt(0, 0)

Accepts

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

Notes

  • Coordinates are 0-based: (0, 0) is the top-left corner
  • x is the column, y is the row

See Also