Wasm-bindgen-test and "no tests to run!"

Hello,

I have a project where I'm trying to add some wasm_bindgen_tests to verify the code under a headless browser. So far everything is working well on my macOS development machine, where I can run the tests under Firefox headless just fine... but on trying to do the same on Linux (Debian or Ubuntu, which I need for CI), I can't get the tests to run.

Here is what I get on macOS:

macos:~/os/endbasic/web> wasm-pack test --firefox --headless
[INFO]: __  Checking for the Wasm target...
    Finished dev [unoptimized + debuginfo] target(s) in 0.09s
[INFO]: __  Installing wasm-bindgen...
    Finished test [unoptimized + debuginfo] target(s) in 0.09s
     Running /Users/jmmv/os/endbasic/target/wasm32-unknown-unknown/debug/deps/endbasic_web-e38108b278b7445b.wasm
Set timeout to 20 seconds...
Running headless tests in Firefox on `http://127.0.0.1:65190/`
Try find `webdriver.json` for configure browser's capabilities:
Not found
running 9 tests                                   

test endbasic_web::store::tests::test_webstore_put ... ok
test endbasic_web::store::tests::test_webstore_get ... ok
test endbasic_web::store::tests::test_webstore_enumerate ... ok
test endbasic_web::store::tests::test_webstore_delete_missing_file ... ok
test endbasic_web::store::tests::test_webstore_delete_ok ... ok
test endbasic_web::store::tests::test_key_serialized ... ok
test endbasic_web::store::tests::test_key_name ... ok
test endbasic_web::store::tests::test_key_parse ... ok
test endbasic_web::store::tests::test_key_for_name ... ok

test result: ok. 9 passed; 0 failed; 0 ignored

and here is what I get on Linux:

debian:~/os/endbasic/web> wasm-pack test --firefox --headless
[INFO]: Checking for the Wasm target...
   Compiling endbasic-web v0.2.0 (/home/jmmv/os/endbasic/web)
    Finished dev [unoptimized + debuginfo] target(s) in 0.80s
    Finished test [unoptimized + debuginfo] target(s) in 0.06s
     Running /home/jmmv/os/endbasic/target/wasm32-unknown-unknown/debug/deps/endbasic_web-30b87b6ae2b1c12f.wasm
no tests to run!

I've even tried to add a trivial tests/wasm.rs file, following online documentation, with a minimum test as follows:

use wasm_bindgen_test::*;

wasm_bindgen_test_configure!(run_in_browser);

#[wasm_bindgen_test]
fn pass() {
    assert_eq!(1, 1);
}

and I get the same behavior.

Looking a bit further, I see that the wasm-bindgen-test-runner has a code snippet to check for tests in wasm-bindgen/main.rs at main · rustwasm/wasm-bindgen · GitHub, and it mentions that there is some bug... which makes it sound suspicious.

Any ideas about what's going on here?

Thanks!

And, of course... typing this post made me reach my own answer. If only I had waited 5 minutes before clicking submit...

Anyway, here is what's going on in case anyone else encounters this problem. There is this recent commit: Fix name collisions with test functions and intrinsics by alexcrichton · Pull Request #2123 · rustwasm/wasm-bindgen · GitHub to disambiguate names for generated symbols.

My Cargo.toml requests wasm-bindgen 0.2 and wasm-bindgen-test 0.2, which seems reasonable(?).

On my macOS machine, Cargo.lock was pinning wasm-bindgen to an old-enough version that didn't have this fix, but wasm-bindgen-test should have been 0.3 to pick up the fix as well. So upon trying this on a fresh Linux box, I got the fix for the wasm-bindgen crate but not for the wasm-bindgen-test crate. Upgrading the latter to 0.3 fixed the issue for me.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.