testing library
Test helpers for dart_tui apps: drive a real Program with keys and messages, read its screen, and compare screens with golden files.
import 'package:dart_tui/dart_tui.dart';
import 'package:dart_tui/testing.dart';
final t = TuiTester(CounterModel());
await t.press('up');
await t.waitFor((screen) => screen.contains('Count: 1'));
expectScreen(t.screen, 'test/goldens/counter.txt');
final result = await t.quit();
It imports no test framework: failures throw TuiTestFailure, so it works
with package:test or any other runner.
Classes
Functions
-
expectScreen(
String actual, String path, {bool? update}) → void -
Compares
actualwith the golden file atpath. -
keyPressFor(
String key) → KeyPressMsg -
The KeyPressMsg a terminal produces for the keystroke
key(see TuiTester.press). -
plainScreen(
String content) → String -
contentwithout escape codes, and with trailing spaces trimmed on every line. This is TuiTester.screen for any string, such as aview().
Exceptions / Errors
- TuiTestFailure
- A failed TuiTester.waitFor or expectScreen.