Closed
Description
Describe the Bug
Using JS snippets prevents wasm-pack
from being able to run tests.
Steps to Reproduce
- Create a new crate.
- Paste this into
Cargo.toml
:
[dependencies]
wasm-bindgen = "0.2"
[dev-dependencies]
wasm-bindgen-test = "0.2"
- Paste this into
src/lib.rs
:
extern crate wasm_bindgen;
#[cfg(test)]
extern crate wasm_bindgen_test;
use wasm_bindgen::prelude::*;
#[cfg(test)]
use wasm_bindgen_test::*;
#[cfg(test)]
#[wasm_bindgen_test]
fn foobar() {
#[wasm_bindgen(inline_js = "export function foo() {}")]
extern "C" {
fn foo();
}
foo();
}
- Run:
$ wasm-pack test --chrome --headless
Actual Behavior
$ wasm-pack test --chrome --headless
[INFO]: Checking for the Wasm target...
Finished dev [unoptimized + debuginfo] target(s) in 0.03s
Finished dev [unoptimized + debuginfo] target(s) in 0.03s
Running target/wasm32-unknown-unknown/debug/deps/foobar-27ec9db4a368c0d0.wasm
error: executing `wasm-bindgen` over the wasm file
caused by: failed to generate bindings for JS import `foo`
caused by: local JS snippets are not supported with `--target nodejs`; see rustwasm/rfcs#6 for more details, but this restriction will be lifted in the future
error: test failed, to rerun pass '--lib'
Error: Running Wasm tests with wasm-bindgen-test failed
Caused by: failed to execute `cargo test`: exited with exit code: 1
Expected Behavior
I expect the tests to run.
Additional Context
I need this to be able to run stdweb
's test suite. I could probably hack around it by having a custom test runner, but I'd rather not do that and just use standard tooling.
Also, it seems somewhat counterintuitive that even though I want to run the tests under headless Chrome they're being built for Node.js by wasm-pack
? Is this expected?
$ wasm-pack --version
wasm-pack 0.8.1
$ wasm-bindgen --version
wasm-bindgen 0.2.42