-
Notifications
You must be signed in to change notification settings - Fork 0
Internals TUI Testing
sipnab's TUI is tested at three levels.
Uses ratatui's TestBackend to render views to an in-memory buffer, then insta for snapshot comparison.
cargo test --features tui --test tui_snapshot_testWhen rendering changes intentionally — --accept rewrites the .snap files in
place, and staging them in the same commit is what keeps CI comparing against
the new rendering:
# Run all of these, in order.
cargo insta test --features tui --accept
git add tests/snapshots/- Create a test function that renders to
TestBackend - Call
insta::assert_snapshot!(buffer_to_string(&terminal)) - Run
cargo insta test --acceptto create the initial snapshot - Commit the
.snapfile
Tests App state transitions without rendering. Uses App::new_test() and App::handle_key().
cargo test --features tui --test tui_state_testDrives the real binary inside a detached tmux session — not a bare PTY. sipnab's TUI queries the terminal at startup (crossterm emits ESC[6n to read the cursor position), and a bare pseudo-terminal has no emulator behind it to answer, so the TUI aborts with "cursor position could not be read". tmux is a terminal emulator: it answers the query, provides a real window size, and lets the test send keys and snapshot the screen with capture-pane. These are #[ignore] by default and need tmux on PATH.
cargo test --features tui --test tui_e2e_test -- --ignoredThese tests are slower (~2s each) and may be flaky in CI.
Website · Repository · Issues · Generated from docs/ — edit there, not here.
Getting started
Using the TUI
CLI & automation
Configuration
Integrations (API & MCP)
Development & internals