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.

Screenshots, video and profiles

Evidence a person can look at.

Screenshots

const shot = await term.screenshot();
await term.screenshot({ name: "after-login" });
await term.screenshot({ path: "docs/menu.png", cursor: false });

Screenshots are pixel exact PNGs of what a person would see: fonts, colors, cursor, wide characters, emoji, box drawing and kitty graphics images. They are 2x by default (scale) and include a small padding around the grid (padding). Without a path they go to the run's artifacts folder.

Video

Record from launch:

const term = launch("htop", { record: true });
// ...
const { video } = await term.close();

Or start and stop around part of a test:

await term.startRecording();
await term.press("F6");
const { path, durationMs } = await term.stopRecording();

From the CLI: testingterm run --video on records every terminal, --video retain-on-failure keeps only the failures.

Videos are H.264 MP4s encoded in process (no ffmpeg needed). Frames are only encoded when the screen changes, at up to fps (default 30). By default the mouse pointer, clicks and keys pressed are drawn into the video so viewers can follow along; turn that off with overlay: false. Recording stops one second after the program exits, so videos don't end with long blank tails.

Profiles

const term = launch("node app.mjs", { profile: true });
// or
await term.startProfile();
const file = await term.stopProfile();

A profile is a Chrome trace you can open at ui.perfetto.dev. It contains:

  • every action and wait, with how long waits took
  • each chunk of program output and its size
  • the program's CPU and memory, sampled every 50ms
  • screenshot and video frame render times

Useful for questions like "how long until the first frame?" or "does this keypress cause a burst of output?".

Where files go

  • Under testingterm run: the folder from --out, or a fresh temp folder printed at the end. Each test gets its own subfolder.
  • In your own scripts: pass artifacts: "some/folder" to launch, or full paths to each call.