Probar: WASM-Native Game Testing

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?

AspectPlaywrightProbar
LanguageTypeScriptPure Rust
BrowserRequired (Chromium)Not needed
Game StateBlack box (DOM only)Direct API access
CI SetupNode.js + browserJust cargo test
Zero JS❌ Violates constraint✅ Pure Rust

Key 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 Example

#![allow(unused)]
fn main() {
use jugar_probar::Assertion;
use jugar_web::{WebConfig, WebPlatform};

#[test]
fn test_game_starts() {
    let config = WebConfig::new(800, 600);
    let mut platform = WebPlatform::new_for_test(config);

    // Run a frame
    let output = platform.frame(0.0, "[]");

    // Verify output
    assert!(output.contains("commands"));

    // Use Probar assertions
    let assertion = Assertion::in_range(60.0, 0.0, 100.0);
    assert!(assertion.passed);
}
}

Running Tests

# All Probar E2E tests
cargo test -p jugar-web --test probar_pong

# Verbose output
cargo test -p jugar-web --test probar_pong -- --nocapture

# Via Makefile
make test-e2e
make test-e2e-verbose

Test Suites

SuiteTestsCoverage
Pong WASM Game (Core)6WASM loading, rendering, input
Pong Demo Features22Game modes, HUD, AI widgets
Release Readiness11Stress tests, performance, edge cases

Total: 39 tests

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

PrincipleApplication
Poka-YokeType-safe selectors prevent typos at compile time
MudaZero-copy memory views eliminate serialization
Genchi GenbutsuProbarDriver abstraction for swappable backends
Andon CordFail-fast mode stops on first critical failure
JidokaQuality built into the type system

Next Steps