Skip to main content

Module testing

Module testing 

Source
Expand description

A harness that drives a component through the same mount and update pipeline the endpoint uses, without HTTP.

Upstream’s Livewire::test() mounts a component, changes its state, calls its actions, and asserts on the result. Testable is that harness in Rust: it calls render::mount and render::update directly, so a test proves the wire pipeline rather than only the method.

let mut test = Testable::mount(registry, "counter", Params::Named(Map::new()))?;
test.assert_set("count", json!(0));

§What a test needs

Mounting renders a view and signs a snapshot, so it reads the framework’s request context: call it inside a request or a framework test. Session- and auth-backed fields need a real HTTP request, which this harness does not create; they hydrate to their defaults.

Structs§

Testable
A component mounted for a test, with its latest markup, snapshot, and effects.