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.

Quick start

Test a terminal app in one file, then run it with one command.

Your first script

Save this as check.mjs next to the program you want to test:

import { launch, expect } from "testingterm";

const term = launch("node menu.mjs");
await expect(term).toHaveText("Main menu");
await term.press("Down");
await term.press("Enter");
await expect(term).toHaveText("You picked Run tests");
await term.screenshot();

Run it:

$ testingterm run check.mjs
✓ check.mjs (142ms)
    /tmp/testingterm/run-.../check/node-4v05-01.png

1 passed in 144ms

import "testingterm" resolves on its own under testingterm run, even when the package isn't installed in the project.

What happened:

  1. launch started node menu.mjs in a 100x30 terminal.
  2. expect(term).toHaveText(...) waited until the text appeared. Assertions retry until they pass or time out (5 seconds by default), so there are no sleeps.
  3. press sent real key events, encoded the way the program asked for them.
  4. screenshot saved a PNG of exactly what a person would see.

One call, no file

For quick checks, pass code directly. launch, expect and test are already in scope:

$ testingterm run -e 'const t = launch("ls -la"); await expect(t).toHaveText("package.json"); await t.screenshot()'

Keep a video

$ testingterm run check.mjs --video on

Videos show the mouse pointer, clicks and keys pressed, so a person can follow what the test did. Use --video retain-on-failure to keep videos only for tests that fail.

Next