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-resultsWhen 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/rowsand useisolate: trueso results don't depend on the runner. --retries 1is a reasonable safety net, but check failures: a test that only passes on retry is usually waiting for the wrong thing.--jsonprints results for other tools to read.- Linux runners and containers work as is. Minimal images need
libatomic1for the Node binary used by the curl installer; the npm package uses your own Node instead.