Skip to content

Quickstart

After installing tui-test, you can either open an interactive shell with open or launch an executable directly with run. Use the language selector in the site header to switch all examples on the site to your preferred language.

open starts the platform’s default shell and tracks prompt readiness, submitted commands, output, and exit codes.

import { TuiTest } from "@microsoft/tui-test";
const terminal = TuiTest.ephemeral("quickstart");
try {
await terminal.open({ cols: 80, rows: 30 });
await terminal.submit("echo hello");
await terminal.waitCommand();
await terminal.expectOutput("hello");
await terminal.expectExitCode(0);
await terminal.screenshot("hello.svg");
} finally {
await terminal.closeQuiet();
}

CLI sessions stay alive in a background daemon across commands until you run close. Library sessions live inside your process and are independent of CLI daemons.

When testing an interactive CLI or full-screen terminal app, launch the executable directly with run instead of going through a shell. Use locators to wait for visible labels and click controls without hard-coded cell coordinates.

import { TuiTest } from "@microsoft/tui-test";
const terminal = TuiTest.ephemeral("app");
try {
await terminal.run("my-app", ["--config", "dev.toml"]);
await terminal.getByText("Ready").expect();
await terminal.getByText("Continue").click();
await terminal.getByText("Saved").expect();
await terminal.press("q");
await terminal.waitExit();
await terminal.expectExitCode(0);
} finally {
await terminal.closeQuiet();
}