wasm-pack: Headless Chrome test fails
š Bug description
Iām currently following this tutorial: https://rustwasm.github.io/docs/book/game-of-life/testing.html. The default tests/web.rs file looks like this:
//! Test suite for the Web and headless browsers.
#![cfg(target_arch = "wasm32")]
extern crate wasm_bindgen_test;
use wasm_bindgen_test::*;
wasm_bindgen_test_configure!(run_in_browser);
#[wasm_bindgen_test]
fn pass() {
assert_eq!(1 + 1, 2);
}
The tutorial suggests that I run wasm-pack test --chrome --headless to āconfirm that the Rust-generated WebAssembly test is workingā. Instead it fails with the following output:
C:\dev\Projekte\Rust\Sandbox\wasm-game-of-life>wasm-pack test --chrome --headless
[INFO]: Checking for the Wasm target...
Finished dev [unoptimized + debuginfo] target(s) in 0.42s
[INFO]: Installing wasm-bindgen...
Finished dev [unoptimized + debuginfo] target(s) in 0.20s
Running target\wasm32-unknown-unknown\debug\deps\wasm_game_of_life-18a0250534315977.wasm
no tests to run!
Running target\wasm32-unknown-unknown\debug\deps\web-1bc24e2bd87521b3.wasm
Running headless tests in Chrome with `C:\Users\Tobias\AppData\Local\.wasm-pack\chromedriver-87c19a493f3a2690\chromedriver.exe`
driver status: exit code: 1
driver stdout:
Starting ChromeDriver 2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1) on port 62230
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
error: failed to find element reference in response
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
Running the test with wasm-pack test --chrome (and opening the page in chrome) is successful, as is running wasm-pack test --firefox --headless.
š¤ Expected Behavior
The test should work and succeed for chrome headless mode.
š Steps to reproduce
cargo generate --git https://github.com/rustwasm/wasm-pack-template- Project Name: wasm-game-of-life
cd wasm-game-of-lifewasm-pack test --chrome --headless
š Your environment
wasm-pack version: 0.7.0 rustc version: 1.33.0 System: Windows 7 64bit Chrome: 73.0.3683.86 (official build) (64-Bit)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 7
- Comments: 20 (12 by maintainers)
Commits related to this issue
- Update `chromedriver` download version Looks like a lot of updates have happened since we first added this! Let's download the most recent stable version. Closes #611 — committed to alexcrichton/wasm-pack by alexcrichton 5 years ago
- Try fix chrome driver As described in workaround here: https://github.com/rustwasm/wasm-pack/issues/611#issuecomment-522093207 — committed to enso-org/ide by farmaazon 4 years ago
I think itās because of incompatible
ChromeDriverandChromeversion.Explanation ChromeDriver 2.46 doesnāt support current Chrome version (76) but itās the default version which
wasm-packinstalls (see https://github.com/rustwasm/wasm-pack/blob/master/src/test/webdriver.rs#L56). I think it also can fail with supported Chrome version if you donāt have the latest 2.46.xx driver (@TobiasWehrumās case). We probably didnāt notice it sooner because 2.46 supports more Chrome versions and maybe newer versions (73+) are more sensitive to incompatible driver versions.Suggestions
wasm-packshould check and install compatible ChromeDriver if necessary. Algorithm for selecting compatible driver is here: https://chromedriver.chromium.org/downloads/version-selection.Workarounds
wasm-packis searching for currently installedchromedriver(see https://github.com/rustwasm/wasm-pack/blob/master/src/test/webdriver.rs#L34) so we can use that fact.PATHenv variable.I ended up manually installing latest chromedriver via brew and that fixed it, not sure about my travis job yet though. (didnāt want to switch to FF just for thisā¦but can do if this doesnāt work). Thanks
I have the same issue as @TobiasWehrum had. I just wanted to mention that I am running Linux and this is probably not a windows-only issue then (as suggested by the label).
As a little addendum, my error message looks like this:
This just occurred to me on Linux (Fedora 37) with a very similar error:
Iām not sure why, but
dnf install chromedriverfixed the problem.Ok no worries, thanks for the help so far @TobiasWehrum! Weāll leave this open for now to see if others end up having it, and next time I get access to Windows I can try to reproduce myself too