@gridland/testing
v0.4.3
Published
Test utilities for [Gridland](https://gridland.io) components — render a TUI component in a test environment and assert against its rendered output.
Readme
@gridland/testing
Test utilities for Gridland components — render a TUI component in a test environment and assert against its rendered output.
Works with any test runner (Bun test, Jest, Vitest). Provides a React-Testing-Library-style API adapted for terminal UIs: query by text, send keys, wait for conditions.
Install
bun add -d @gridland/testingAPI
renderTui(element, options?)→TuiInstance— mount a component in a virtual terminalScreen— query helpers: find text, inspect cells, dump the framebufferKeySender— simulate keyboard input (arrows, tab, enter, typed characters)waitFor(predicate, options?)— async assertion helper with retry
Example
import { renderTui, waitFor } from "@gridland/testing"
import { Counter } from "./counter"
test("counter increments on space", async () => {
const { screen, keys, cleanup } = renderTui(<Counter />)
expect(screen.findText("count: 0")).toBeTruthy()
keys.press("space")
await waitFor(() => screen.findText("count: 1"))
cleanup()
})Documentation
Full docs at gridland.io/docs
