sweet
Write many tests quickly and cleanly.
Features
- 🔥 Parallel
- 🕙 Async
- 🌍 WASM
- ☮️ Intuitive matchers
- 🌈 Pretty output
pub use *;
sweet!
Native
The Sweet harness has a couple of advantages over default tests.
- Suites - Organize your tests into collections
- Matchers - Matchers specific to a type enables a harness to output more intuitive results instead of an opaque
panic!-
expect.not.to_start_with //expected: NOT to start with 'bar' //received: 'foo'
-
- Single Binary - The default intergration test approach creates a seperate binary for each test, which ramps up compile times, see this blog for more info.
Quickstart
- edit
cargo.toml[] = # current version here [[]] = "sweet" = "test/sweet.rs" = false - create file
test/sweet.rspub use *; sweet! - run
cargo test --test sweet
Features - CLI
- Run
cargo test --test sweet
- With watch
cargo watch -q -x 'test --test sweet -- -w'- Clears terminal on each run
- Returns an exit code zero (cleaner output)
- Specify filename
cargo test --test sweet -- my_test- Use forward-slash
/to specify directoriescargo test --test sweet -- my_dir/my_test
WASM
The wasm test harness has different priorities from wasm-bindgen-test
- UI - Tests are run in a *mostly isolated iframe (see TODO)
- Interactive - the runner will list all tests and they can be run at-will in the browser.
Quickstart
- Follow native quickstart
- install the cli
cargo install forky_cli
forky_cli sweet- or for workspaces
forky_cli sweet -p my_package
- or for workspaces
Features - Summary
- Pretty Messages
- Success
- In progress
- Failure
- Success
Dont Panic
Or do, thats ok too. Currently you'll get the prettiest output by using the provided matchers that return results intstead of panicing, especially in wasm as panic=unwind isnt yet supported for wasm.
Reference
TODO
- wasm
- node & headless support
- seperate interactive runner from tests, currently the runner code, css etc is included.
- catch panics in test, like how wasm-bindgen-test does it


