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.

Running in CI

Install from npm and run your terminal tests on every push.

Install testingterm as a dev dependency. The npm package carries the engine for the runner's platform, so nothing else is needed: no display, no GPU, no ffmpeg.

$ npm install --save-dev testingterm
{
  "scripts": {
    "test:terminal": "testingterm run tests/*.test.mjs --video retain-on-failure --out test-results"
  }
}

GitHub Actions

name: terminal tests
on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: actions/setup-node@v5
        with:
          node-version: 24
      - run: npm ci
      - run: npm run test:terminal
      - uses: actions/upload-artifact@v4
        if: failure()
        with:
          name: terminal-test-results
          path: test-results

When a test fails, test-results holds a screenshot, the scrollback and (with --video retain-on-failure) a video of the failing terminal.

Other test runners

The library works on its own, so you can use it from any runner instead of testingterm run:

import { test } from "node:test";
import { launch, expect } from "testingterm";

test("prints help", async () => {
  const term = launch(["node", "bin/cli.mjs", "--help"]);
  await expect(term).toHaveText("usage:");
  await term.close();
});

Close terminals yourself (or let the process exit) when you use another runner; testingterm run does it for you.

Tips

  • Pin cols/rows and use isolate: true so results don't depend on the runner.
  • --retries 1 is a reasonable safety net, but check failures: a test that only passes on retry is usually waiting for the wrong thing.
  • --json prints results for other tools to read.
  • Linux runners and containers work as is. Minimal images need libatomic1 for the Node binary used by the curl installer; the npm package uses your own Node instead.