I'm writing a frontend in WASM
by using the seed
framework.
I want to test one of my modules with unittests, but I can't make them to test WASM
code. Here's my test suite:
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn check_non_wasm() {
assert_eq!("test", "test");
}
#[test]
fn check_home() {
assert_eq!(Urls::new().home().to_string(), "/");
}
}
The first tests passes, as there isn't used anything related to WASM
. The other test fails with the following error:
thread 'urls::tests::check_home' panicked at 'cannot call wasm-bindgen imported functions on non-wasm targets'
If I'll run cargo make test --chrome
it doesn't even see these tests.
I've tried to run cargo test --target wasm32-unknown-unknown
, and it fails with following error:
could not execute process `C:\Users\djenty\w\frontend\target\wasm32-unknown-unknown\debug\deps\w_frontend-2b6de747c6501f70.wasm` (never executed)
rustup
shows that the target is installed:
installed targets for active toolchain
--------------------------------------
wasm32-unknown-unknown
x86_64-pc-windows-msvc
active toolchain
----------------
stable-x86_64-pc-windows-msvc (default)
rustc 1.54.0 (a178d0322 2021-07-26)
What am I missing here?