testingterm
These docs were written by an AI agent. They were checked against the code, but may still contain mistakes; when in doubt, trust testingterm --help and the types.

Terminal capabilities

Test how a program behaves in terminals that support less.

Your users run your program in many terminals: Ghostty and kitty with every modern feature, Apple's Terminal with 256 colors, tmux, a CI log with no colors at all. capabilities lets one testingterm imitate them.

launch("./my-tui", { capabilities: "apple-terminal" });
launch("./my-tui", { capabilities: { mouse: false, colors: 256 } });
launch("./my-tui", { capabilities: { preset: "tmux", kittyGraphics: true } });

How it behaves

A disabled feature behaves like a terminal that doesn't have it:

  • Requests to turn it on are ignored (for example the escape sequences that enable mouse reporting or the alternate screen).
  • Queries for it are answered "not supported", so programs that detect features see the same thing they would in that terminal.
  • Lower color depths are approximated the way real terminals do it: truecolor becomes the nearest of 256, or of the 16 ANSI colors, or no color at all.
  • TERM and COLORTERM match: COLORTERM=truecolor only with truecolor, and TERM defaults to xterm-256color, xterm or dumb depending on colors.

Presets

Preset Imitates
full Everything testingterm supports (default)
xterm No kitty keyboard or graphics, no synchronized output
apple-terminal 256 colors, no kitty protocols, no clipboard, links or synchronized output
tmux TERM=tmux-256color, no kitty protocols
basic TERM=xterm, 16 colors, few extras
dumb TERM=dumb, no colors, no mouse, no alternate screen

Presets are approximations of those terminals, good for catching programs that assume a feature exists.

Features

Option Default Controls
colors "truecolor" "truecolor", 256, 16, 8 or "none"
term from colors The TERM value
mouse true Mouse reporting
bracketedPaste true Bracketed paste
focusEvents true Focus in and out reports
synchronizedOutput true Synchronized output (mode 2026)
alternateScreen true Full screen apps' alternate screen
kittyKeyboard true The kitty keyboard protocol
kittyGraphics true The kitty graphics protocol
clipboard true OSC 52 clipboard writes
hyperlinks true OSC 8 links
title true Setting the window title
graphemes true Grapheme clustering (mode 2027), which decides emoji widths

Example: works without a mouse

test("works without a mouse", async ({ launch }) => {
  const term = launch(["node", "app.mjs"], { capabilities: { mouse: false } });
  await expect(term).toHaveText("0 of 1 done");
  expect((await term.screen()).mouseTracking).toBe(false);
  await term.press("space");
  await expect(term).toHaveText("1 of 1 done");
});

From the CLI

$ testingterm new --capabilities apple-terminal -- ./my-tui
$ testingterm new --disable mouse,kitty-keyboard --colors 16 -- ./my-tui
$ testingterm run tests/*.mjs --capabilities basic

--enable turns features back on after a preset; --term sets TERM. TESTINGTERM_CAPABILITIES sets a default preset for every terminal.