Open Source / Crate

browser-tester

browser-tester is a deterministic browser-like test runtime implemented in pure Rust. It validates DOM and event behavior without launching a real browser.

Rust Deterministic Runtime DOM Testing

What This Crate Is Good At

browser-tester focuses on predictable form/UI behavior tests rather than full browser rendering compatibility.

Rust-Only Runtime

Runs inside a single Rust process. No external browser, WebDriver, or Node.js dependency.

Deterministic Execution

Built for repeatable tests by design: fake clock, deterministic random seed, and explicit timer control APIs.

DOM + Event Testing

Supports practical browser-like flows: selectors, inline script execution, event propagation, and DOM updates.

Fast Local Feedback

Fast feedback cycle for form-centric UI tests, while keeping failure output focused on selectors and expected/actual values.

Quick Start

Create a harness from HTML, run interactions, and assert DOM results. Start with a small fixture and expand with timer/mock APIs.

Install

cargo add browser_tester

Basic Example

Main API Surface

Harness Actions + Assertions

Core DOM test operations: Harness::from_html, type_text, set_checked, click, submit, and assertion helpers for text/value/checked/existence.

Deterministic Timers

Control asynchronous behavior with a fake clock. Advance time deterministically using advance_time, advance_time_to, flush, and timer inspection APIs.

Built-in Mocks

Inject fetch responses and dialog outcomes with set_fetch_mock, enqueue_confirm_response, and enqueue_prompt_response to keep tests isolated.

Trace & Diagnostics

Enable trace logs and extract event/timer flow when a test fails. Useful for debugging event order and default action behavior.

Runtime Policy

  • eval is intentionally unsupported to preserve security and determinism.
  • This runtime targets practical test scenarios, not 100% real-browser compatibility.
  • External network I/O is out of scope; use fetch mocks for test coverage.

If you need additional browser APIs for your test suite, open an issue with a minimal fixture to discuss scope and priority.