Working through the wasm book on testing, on a machine with no browsers on it; but I have node.
https://rustwasm.github.io/docs/book/game-of-life/testing.html suggested I could run with --node to test with node.
I don't know if this is wasm-pack glue or bindgen behaviour sorry.
The tests should have run.
Install a new Linux VM, don't install a browser, webdriver etc. Follow the WASM book precisely including installing node. Access the demo page via the network.
Run
wasm-game-of-life$ wasm-pack test --node
[INFO]: Checking for the Wasm target...
Finished dev [unoptimized + debuginfo] target(s) in 0.02s
[INFO]: Installing wasm-bindgen...
Finished dev [unoptimized + debuginfo] target(s) in 0.02s
Running target/wasm32-unknown-unknown/debug/deps/wasm_game_of_life-c3a3f049cb26741c.wasm
no tests to run!
Running target/wasm32-unknown-unknown/debug/deps/web-3188965b70e2da5b.wasm
error: failed to find a suitable WebDriver binary or remote running WebDriver to drive
headless testing; to configure the location of the webdriver binary you can use
...
Adding --headless results in this error:
``
wasm-pack test --node --headless
Error: The--headless` flag only applies to browser tests. Node does not provide a UI, so it doesn't make sense to talk about a headless version of Node tests.
But adding NO_HEADLESS=1 bypasses that (which I presume is was-pack logic), and then fails on a port in use error. Stracing to see what port is in use ends up with a non-terminating process for some reason, so I'm not entirely sure whats going on, and my tuits for investigating this have run dry for now.
NO_HEADLESS=1 wasm-pack test --node
Finished dev [unoptimized + debuginfo] target(s) in 0.02s
Finished dev [unoptimized + debuginfo] target(s) in 0.02s
Running target/wasm32-unknown-unknown/debug/deps/wasm_game_of_life-c3a3f049cb26741c.wasm
no tests to run!
Running target/wasm32-unknown-unknown/debug/deps/web-3188965b70e2da5b.wasm
error: failed to spawn server
caused by: Address in use (os error 98)
error: test failed, to rerun pass '--test web'
Error: Running Wasm tests with wasm-bindgen-test failed
Caused by: failed to execute cargo test: exited with exit code: 1
```
Include the relevant details of your environment.
wasm-pack version: wasm-pack 0.8.1
rustc version:rustc 1.38.0 (625451e37 2019-09-23
same issue here :(
I think I have a related issue which is that running wasm-pack test --node opens up an instance of chrome and runs the tests there which is definitely not what I'd expect.
Actually, my problem was that I had included an invocation of the wasm_bindgen_test_configure!(run_in_browser) macro by copying and pasting from the tutorial without realizing what was implied by it. Took it out and now tests run in node just fine.
Most helpful comment
Actually, my problem was that I had included an invocation of the
wasm_bindgen_test_configure!(run_in_browser)macro by copying and pasting from the tutorial without realizing what was implied by it. Took it out and now tests run in node just fine.