tmux-testing
tmux-based TUI testing for autonomous text and ANSI verification
SKILL.md.claude/skills/tmux-testing
GitHubtmux-Based TUI Testing
Use this skill for durable, CI-friendly tests of interactive invowk tui
commands when text output, ANSI state, keyboard navigation, or completion
behavior needs to be verified. Use tui-testing only for ad hoc VHS visual
debugging or documentation demos.
Pre-write guardrails: Before writing *_test.go, follow
.agents/skills/testing/SKILL.md § "Pre-Write Checklist".
Current Harness
Durable tmux coverage lives in tests/cli/tui_tmux_test.go. The command
coverage guardrail in cmd/invowk/cmd_coverage_test.go requires every
interactive TUI exemption to have a matching tmux E2E marker.
Run the focused checks:
go test -v -run 'TestTUI_' ./tests/cli/...
go test -v -run TestTUIExemptionTmuxCoverage ./cmd/invowk/...
Do not create tests/tui/*.sh or tests/tui/run-all.sh; that shell harness no
longer exists. Add new coverage to the Go tmux harness.
Workflow
- Build or locate the invowk test binary using the existing helpers in
tests/cli/tui_tmux_test.go. - Start a unique per-test tmux session through the Go helper contract:
requireTmux, serialized session setup, stale-session cleanup, deterministic100x30size, input-settle delays, and independent cleanup timeouts. - Send the command and keys with
tmux send-keys. - Poll captured pane output until the expected prompt, selection, or exit marker appears.
- Assert on plain text for behavior and ANSI capture only when style matters.
Use
INVOWK_EXIT:$?or a command-specific marker for completion/exit checks, and quote filesystem paths with the existing helpers. - Always clean up the session with
t.Cleanup.
Do not copy ad hoc tmux shell commands into tests. If you need to experiment
manually, keep the experiment outside the committed test and port the result back
to tests/cli/tui_tmux_test.go.
When adding a new interactive TUI command, update the txtar exemption, update
the tmux marker map in cmd/invowk/cmd_coverage_test.go, add
TestTUI_<Command> with marker text, then run the two focused checks above.
Command Notes
tui choosesingle-select is the default.- Multi-select uses
--limit Nor--no-limit; there is no--multiflag. - Prefer representative keyboard flows over asserting every frame.
- Keep tests resilient to harmless ANSI/style changes unless the style is the behavior under test.
When To Use Something Else
Use testscript for non-interactive commands and pipe-based TUI helpers such as
tui format or tui style.
Use unit tests under internal/tui/ for Bubble Tea model update logic.
Use VHS through tui-testing only when a screenshot is needed for visual
inspection or a documentation demo.