Playwright-Compatible Testing for WASM + TUI Applications
Pure Rust • Zero JavaScript • Games • Simulations • Web Apps
Probar (Spanish: "to test/prove") is distributed as two crates:
| Crate | Purpose | Install |
|---|---|---|
| jugar-probar | Library for writing tests | cargo add jugar-probar --dev |
| probador | CLI tool for running tests | cargo install probador |
Add to your Cargo.toml:
[dev-dependencies]
jugar-probar = "0.3"use jugar_probar::prelude::*;cargo install probador# Validate a playbook state machine
probador playbook login.yaml --validate
# Run with mutation testing (M1-M5 falsification)
probador playbook login.yaml --mutate
# Export state diagram
probador playbook login.yaml --export svg -o diagram.svg
# Start dev server for WASM
probador serve --port 8080Probar is a Playwright-compatible testing framework written in pure Rust. It provides comprehensive testing for:
- WASM Applications - Games, simulations, web apps running in browsers
- TUI Applications - Terminal interfaces built with ratatui/crossterm
- Headless Testing - Fast CI/CD without browser overhead
Probar introduces GUI Coverage - a new paradigm for measuring UI test completeness:
use jugar_probar::gui_coverage;
// Define what needs testing (one line!)
let mut gui = gui_coverage! {
buttons: ["start", "pause", "quit"],
screens: ["title", "playing", "game_over"]
};
// Record interactions during tests
gui.click("start");
gui.visit("title");
// Get coverage - one line!
println!("{}", gui.summary()); // "GUI: 33% (1/3 elements, 1/3 screens)"
assert!(gui.meets(80.0)); // Fail if below 80%// Familiar Playwright-style locators and assertions
let button = page.locator("button").with_text("Start Game");
button.click().await?;
expect(&score).to_have_text("100").await?;| Target | Description | Use Case |
|---|---|---|
| WASM Browser | Chrome DevTools Protocol (CDP) | Games, web apps, simulations |
| WASM Headless | wasmtime runtime | Fast CI, logic testing |
| TUI | ratatui/crossterm backends | Terminal applications |
| Feature | Description |
|---|---|
| Browser Automation | Chrome DevTools Protocol (CDP) via chromiumoxide |
| WASM Runtime Testing | Logic-only testing via wasmtime (no browser overhead) |
| TUI Testing | Frame capture and assertion for terminal UIs |
| GUI Coverage | Provable UI element and interaction coverage |
| Visual Regression | Image comparison for UI stability |
| Accessibility Auditing | WCAG compliance checking |
| Deterministic Replay | Record and replay sessions with seed control |
| Monte Carlo Fuzzing | Random input generation with invariant checking |
use jugar_probar::prelude::*;
#[test]
fn test_calculator_gui() {
// Create driver (works for TUI or WASM)
let mut driver = WasmDriver::new();
// Track GUI coverage
let mut gui = gui_coverage! {
buttons: ["btn-7", "btn-times", "btn-6", "btn-equals"],
screens: ["calculator"]
};
// Test: 7 x 6 = 42
driver.type_input("7 * 6");
gui.click("btn-7");
gui.click("btn-times");
gui.click("btn-6");
driver.click_equals();
gui.click("btn-equals");
gui.visit("calculator");
assert_eq!(driver.get_result(), "42");
assert!(gui.is_complete()); // 100% GUI coverage!
}| Feature | Description | Dependencies |
|---|---|---|
tui |
TUI testing support (default) | ratatui, crossterm |
browser |
CDP browser automation | chromiumoxide, tokio |
runtime |
WASM runtime testing | wasmtime |
derive |
Type-safe derive macros | probar-derive |
# Run all tests
cargo test
# Run with coverage
cargo llvm-cov --html
# Watch mode
cargo watch -x test# Run tests with probador
probador test
# Generate coverage reports
probador coverage --html
# Watch mode with hot reload
probador watch tests/
# Serve WASM application
probador serve --port 8080 --cors# Run the GUI coverage example
cargo run --example gui_coverage -p jugar-probarOutput:
=== GUI Coverage Example ===
1. Using gui_coverage! macro (simplest)...
GUI: 50% (1/3 elements, 2/3 screens)
2. Calculator preset (20 buttons + 2 screens)...
GUI: 60% (14/20 elements, 1/2 screens)
3. Achieving 100% coverage...
GUI: 100% (3/3 elements, 1/1 screens)
Complete? true
The repository includes a full showcase calculator demonstrating 100% test coverage:
# Run GUI coverage report
cargo run -p showcase-calculator --example gui_coverage_report
# Run TUI version
cargo run -p showcase-calculator --example calculator_tui
# View WASM version
cd crates/showcase-calculator/www && python3 -m http.server 8080
# Open http://localhost:8080Probar is built on pragmatic testing principles:
| Principle | Description |
|---|---|
| Error Prevention | Type-safe selectors prevent runtime errors |
| Efficiency | Zero-copy memory views minimize overhead |
| Fail-Fast | Immediate feedback on test failures |
| Balanced Testing | Even coverage across all UI elements |
| Continuous Improvement | Mutation testing for test quality |
- Book - Comprehensive guide
- API Docs - Rust documentation
- GUI Coverage Guide - GUI coverage tutorial
- Examples - 20+ runnable examples
| Example | Description |
|---|---|
gui_coverage |
GUI coverage tracking |
soft_assertions |
Collect multiple failures |
retry_assertions |
Retry with backoff |
pong_simulation |
Game simulation testing |
accessibility_demo |
WCAG compliance |
watch_mode |
Hot-reload testing |
Run any example:
cargo run --example <name> -p jugar-probarprobar/
├── crates/
│ ├── probar/ # jugar-probar library
│ ├── probar-cli/ # probador CLI
│ ├── probar-derive/ # Derive macros
│ └── showcase-calculator/ # 100% coverage demo
├── book/ # mdBook documentation
└── docs/ # Specifications
Contributions are welcome! Please follow these guidelines:
- Fork the repository and create your branch from
main - Run tests before submitting:
cargo test - Ensure formatting:
cargo fmt - Check lints:
cargo clippy --all-targets --all-features - Update documentation if you change public APIs
- Add tests for new functionality
git clone https://github.com/paiml/probar.git
cd probar
cargo build
cargo testmake lint # Clippy checks
make test # All tests
make coverage # Coverage reportMIT OR Apache-2.0
Probar - by Pragmatic AI Labs