@effect-native/tui-testing-library
v0.1.0
Published
PTY-based testing utilities for TUI applications with Ghostty WASM emulator
Readme
@effect-native/tui-testing-library
PTY-based testing utilities for TUI applications with Ghostty WASM emulator.
Overview
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
Usage
Tests in this package use Bun's test runner (bun:test), not Vitest.
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!")
})Running Tests
# Run tests with Bun
bun test
# Run with coverage
bun test --coverage