Skip to content

Comparison

How Termless compares with other approaches to testing terminal applications.

Termless vs pexpect / expect

pexpect (Python) and expect (Tcl) match text patterns on a raw byte stream. They work, but they operate without any understanding of the terminal as a 2D grid.

Aspectpexpect / expectTermless
LanguagePython / TclTypeScript
Terminal modelNone -- raw byte streamFull in-process emulator
Text matchingRegex on output bytesStructured cell-level access
Style assertionsNot possibletoBeBold(), toHaveFg("#ff0000")
Cursor stateNot availablePosition, visibility, style
Terminal modesNot availableAlt screen, bracketed paste, mouse tracking
ScrollbackNot availableterm.scrollback, line count
ScreenshotsNot supportedSVG and PNG snapshots
Speed (in-memory)N/A (process-only)Sub-millisecond
Multiple backendsSingle PTY11 backends
FlakinessTiming-sensitive regexAuto-retry matchers with lazy views

When to prefer pexpect: You're in a Python-only environment and only need basic output matching. pexpect is also useful for non-terminal process automation (serial ports, SSH sessions) where Termless's terminal model isn't relevant.

Termless vs Playwright + ttyd

You can test terminal apps by running them inside ttyd (a web-based terminal) and automating the browser with Playwright. This works but adds significant complexity:

AspectPlaywright + ttydTermless
ArchitectureBrowser + WebSocket + ttyd + PTYIn-process emulator
DependenciesChromium, ttyd, Node.jsNode.js or Bun only
SetupStart ttyd server, launch browser, connectcreateTestTerminal()
SpeedSeconds per test (browser overhead)Sub-millisecond (in-memory)
CI requirementsHeadless browser, display serverNothing extra -- runs headless
Cell-level assertionsParse DOM from xterm.js canvasNative term.cell(r, c) API
Screenshot testingBrowser screenshots (non-deterministic)Deterministic SVG/PNG
DebuggingBrowser DevToolsterm.screenshotSvg() or term.screen.getText()

When to prefer Playwright + ttyd: You need to test a web-based terminal specifically (e.g., verifying your xterm.js integration renders correctly in a real browser).

Termless vs tmux send-keys

Shell scripts that use tmux send-keys and tmux capture-pane can drive terminal apps:

bash
tmux new-session -d -s test './my-app'
tmux send-keys -t test 'q' Enter
tmux capture-pane -t test -p | grep "Expected output"
Aspecttmux send-keysTermless
LanguageShell scriptTypeScript
Assertionsgrep / diff on captured text21+ typed matchers
Style checkingNot possibleBold, italic, colors, underline
Error messages"grep failed"Diff showing expected vs actual
Test organizationAd-hoc scriptsStandard test framework (Vitest)
ParallelismManual session managementAutomatic per-test isolation
CI integrationCustom scriptsStandard bun vitest run

When to prefer tmux: Quick one-off smoke tests in a shell script, or when the test environment only has tmux available.

Termless vs Raw String Assertions

The simplest approach: capture stdout and match on strings.

typescript
// Raw string assertion
const { stdout } = await exec("./my-cli --help")
expect(stdout).toContain("Usage:")
AspectString assertionsTermless
What you teststdout textFull terminal state
ANSI handlingEscape codes pollute outputParsed by emulator -- invisible to assertions
Colors and stylesNot possibletoHaveFg(), toBeBold()
Interactive appsNot possible (no stdin)term.press(), term.click()
Cursor positionNot availabletoHaveCursorAt(x, y)
Layout verificationFragile string matchingtoMatchLines(), row/cell selectors

When to prefer raw strings: Non-interactive CLI tools where you only care about text output. If the program prints a result and exits, stdout capture is simpler and faster.

When NOT to Use Termless

Termless is designed for testing terminal applications. It's the wrong tool for:

  • Non-interactive CLI output. If you just need to check that my-tool --version prints 1.0.0, capture stdout directly. No terminal emulator needed.
  • Pure API testing. If you're testing business logic that happens to live in a TUI app, test the logic directly -- don't route through the terminal layer.
  • Web application testing. Use Playwright or Cypress. Termless tests terminal apps, not browsers.
  • Performance benchmarking. Termless adds emulator overhead. Benchmark your app's rendering pipeline directly, not through an intermediary.

Summary

ApproachBest for
TermlessTUI testing with rich assertions (colors, cursor, modes, screenshots)
pexpectPython-based process automation, serial ports
Playwright + ttydTesting web-based terminal UIs
tmux send-keysQuick shell-script smoke tests
Raw string assertionsNon-interactive CLI output