PTY-based testing utilities for TUI applications with Ghostty WASM emulator
npm install @effect-native/tui-testing-libraryPTY-based testing utilities for TUI applications with Ghostty WASM emulator.
This library provides testing utilities for terminal user interface (TUI) applications using:
- Ghostty WASM: High-fidelity terminal emulation via WebAssembly
- PTY spawning: Real process execution with pseudo-terminal support
- Screen assertions: Text matching, ANSI color verification, and visual testing
Tests in this package use Bun's test runner (bun:test), not Vitest.
``typescript
import { describe, test, expect, beforeAll, afterEach } from "bun:test"
import { GhosttyHarness } from "@effect-native/tui-testing-library/GhosttyHarness"
let harness: GhosttyHarness
beforeAll(async () => {
harness = await GhosttyHarness.createAsync()
})
afterEach(() => {
harness.cleanup()
})
test("renders menu correctly", async () => {
const term = harness.createTerminal(40, 10)
await harness.write(term, "Hello, \x1b[32mWorld\x1b[0m!")
expect(harness.screenshot(term)).toContain("Hello, World!")
})
`
`bashRun tests with Bun
bun test