jugar-probar
Probar (Spanish: "to test/prove") is a pure Rust testing framework for WASM games that provides full Playwright feature parity while adding WASM-native capabilities.
Why Probar?
| Aspect | Playwright | Probar |
|---|---|---|
| Language | TypeScript | Pure Rust |
| Browser | Required (Chromium) | Not needed |
| Game State | Black box (DOM only) | Direct API access |
| CI Setup | Node.js + browser | Just cargo test |
| Zero JS | Violates constraint | Pure Rust |
Features
Playwright Parity
- CSS, text, testid, XPath, role-based locators
- All standard assertions (visibility, text, count)
- All actions (click, fill, type, hover, drag)
- Auto-waiting with configurable timeouts
- Network interception and mobile emulation
WASM-Native Extensions
- Zero-copy memory views - Direct WASM memory inspection
- Type-safe entity selectors - Compile-time verified game object access
- Deterministic replay - Record inputs with seed, replay identically
- Invariant fuzzing - Concolic testing for game invariants
- Frame-perfect timing - Fixed timestep control
- WCAG accessibility - Color contrast and photosensitivity checking
Quick Start
Add to your Cargo.toml:
[]
= { = "../jugar-probar" }
Write tests using WebPlatform directly:
use Assertion;
use ;
Examples
# Deterministic simulation with replay verification
# Playwright-style locator API demo
# WCAG accessibility checking
Example Output
=== Probar Pong Simulation Demo ===
Initial state:
Ball: (400.0, 300.0)
Paddles: P1=300.0, P2=300.0
Score: 0 - 0
Simulating 300 frames...
Final state after 300 frames:
Ball: (234.5, 412.3)
Paddles: P1=180.0, P2=398.2
Score: 2 - 1
State valid: true
Recording simulation (seed=42, frames=500)...
Completed: true
Final hash: 6233835744931225727
Replaying simulation...
Determinism verified: true
Hashes match: true
Architecture
Dual-Runtime Strategy
┌─────────────────────────────────┐ ┌─────────────────────────────────┐
│ WasmRuntime (wasmtime) │ │ BrowserController (Chrome) │
│ ───────────────────────── │ │ ───────────────────────── │
│ Purpose: LOGIC-ONLY testing │ │ Purpose: GOLDEN MASTER │
│ │ │ │
│ ✓ Unit tests │ │ ✓ E2E tests │
│ ✓ Deterministic replay │ │ ✓ Visual regression │
│ ✓ Invariant fuzzing │ │ ✓ Browser compatibility │
│ ✓ Performance benchmarks │ │ ✓ Production parity │
│ │ │ │
│ ✗ NOT for rendering │ │ This is the SOURCE OF TRUTH │
│ ✗ NOT for browser APIs │ │ for "does it work?" │
└─────────────────────────────────┘ └─────────────────────────────────┘
Toyota Way Principles
| Principle | How Probar Applies It |
|---|---|
| Poka-Yoke | Type-safe selectors make typos impossible at compile time |
| Muda | Zero-copy memory views eliminate serialization waste |
| Genchi Genbutsu | ProbarDriver abstraction allows swapping browser backends |
| Andon Cord | Fail-fast mode stops on first critical failure |
| Jidoka | Quality built into the type system |
API Overview
Assertions
use Assertion;
// Value equality
let eq = equals;
// Numeric range
let range = in_range;
// Boolean checks
let truthy = is_true;
// Approximate equality (floats)
let approx = approx_eq;
Simulation
use ;
// Record a simulation
let config = new;
let recording = run_simulation;
// Replay and verify determinism
let replay = run_replay;
assert!;
Fuzzing
use ;
let seed = from_u64;
let mut agent = new;
// Generate random inputs
let inputs = agent.next_inputs;
Running Tests
# Run all Probar E2E tests for Pong
# Run with verbose output
# Via Makefile
Test Coverage
The Probar test suite (probar_pong.rs) includes 39 tests covering:
| Suite | Tests | Coverage |
|---|---|---|
| Pong WASM Game (Core) | 6 | WASM loading, rendering, input |
| Pong Demo Features | 22 | Game modes, HUD, AI widgets |
| Release Readiness | 11 | Stress tests, performance, edge cases |
License
MIT OR Apache-2.0