You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One other difference is that the tests must be in the root of the crate, or
within a pub mod. Putting them inside a private module will not work.
But seem this code is just works now:
use web_sys::js_sys::Math;fnrand() -> usize{Math::floor(Math::random()*10.0)asusize}#[cfg(test)]mod tests {use wasm_bindgen_test::wasm_bindgen_test;use web_sys::console;use wasm_bindgen_test::console_log;#[wasm_bindgen_test]fnit_works(){
console::info_1(&"THIS IS WORKS".into());console_log!("This is works too");let rand = super::rand();assert!(rand<0)}}
Run with:
wasm-pack test --node
Output:
failures:
---- wasm_test_bug::tests::it_works output ----
log output:
This is works too
info output:
THIS IS WORKS
error output:
panicked at src/lib.rs:20:9:
assertion failed: rand < 0
Additional Details
Node version
v20.13.1
wasm-bindgen version
wasm-bindgen 0.2.92
wasm-pack version
wasm-pack 0.12.1
The text was updated successfully, but these errors were encountered:
Summary
From the docs:
But seem this code is just works now:
wasm-pack test --node
Output:
Additional Details
The text was updated successfully, but these errors were encountered: