sweet
Write many tests quickly and cleanly.
Very early stage warning, do not use seriously!
Features
- 🔥 Parallel
- 🕙 Async
- 🌍 WASM UI tests
- ☮️ Intuitive matchers
- 🌈 Pretty output
Quickstart - Native
- edit
cargo.toml[] = # current version here [[]] = "sweet" = "test/sweet.rs" - create file
test/sweet.rspub use *; sweet! - run
cargo run --example sweet
Quickstart - WASM
- Follow native quickstart
- install the helper cli:
cargo install forky_cli - add some wasm matchers to your test
//mount a div in a framework of your choice, we'll use leptos here :) mount; expect_el?.to_contain_text?; - run
forky sweet- requires wasm-bindgen-cli

Features
Performance
Sweet produces a single binary for each crate. The default rust intergration test runner creates a seperate binary for each test, which ramps up compile times, see this blog for more info.
The wasm runner
Args (native)
- filter by filename:
cargo run --example sweet -- some_dir/my_test -wargumentcargo watch -q -x 'run --example sweet -- -w'- Clears terminal on each run
- Returns an exit code zero (cleaner output)
Matchers
Instead of an opaque panic!, matchers provide the runner with enough info to produce a highly descriptive failure:
expect.not.to_start_with?;
/*
Expected: NOT to start with 'foo'
Received: foobar
*/
Async Matchers
Lots of web stuff happens at weird times, so we've got helpers like poll_ok, which will wait for 4 seconds before failing.
let _handle = set_timeout;
poll_ok.await?
.to_contain_text?;
Informative outputs
- Long running tests show which suite is hanging
- Failures are highly descriptive
Misc
Why use [[example]] instead of [[test]]
This makes it easier for the wasm test runner to produce cleaner output, but if you're only running native tests feel free to use [[test]] with harness=false.
What about wasm-bindgen-test?
Sweet has different priorities from wasm-bindgen-test in its current state.
- Interactive - the runner will list all tests and they can be run at-will in the browser.
- UI - Tests are run in a mostly isolated iframe (see TODO)
TODO
- wasm
- node & headless support
- seperate interactive runner from tests, currently the runner code, css etc is included.

