Skip to content

Commit 71dbd08

Browse files
authored
Default to headless testing for the test runner (#610)
We've gotten a number of reports that the interactive tests are a bit surprising and confusing (also because it barely prints anything!). Instead let's default to headless testing which matches the Rust style of testing much better. The error message for a missing WebDriver binary has been updated with a note of how to *not* do headless testing and the message for interactive testing was also updated to display more information as well.
1 parent 7cc5dcf commit 71dbd08

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

crates/cli/src/bin/wasm-bindgen-test-runner/headless.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@ although more driver support may be added! You can download these at:
210210
* chromedriver - http://chromedriver.chromium.org/downloads
211211
* safaridriver - should be preinstalled on OSX
212212
213+
If you would prefer to not use headless testing and would instead like to do
214+
interactive testing in a web browser then you can specify `NO_HEADLESS=1` as
215+
an environment variable. When rerun the tests will start a server that you can
216+
visit in a web browser, and headless testing should not be used.
217+
213218
If you're still having difficulty resolving this error, please feel free to open
214219
an issue against rustwasm/wasm-bindgen!
215220
")

crates/cli/src/bin/wasm-bindgen-test-runner/main.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ fn rmain() -> Result<(), Error> {
122122
}
123123
node = !custom.payload().contains(&0x01);
124124
}
125-
let headless = env::var("CI").is_ok();
125+
let headless = env::var("NO_HEADLESS").is_err();
126126

127127
// Make the generated bindings available for the tests to execute against.
128128
shell.status("Executing bindgen...");
@@ -159,7 +159,12 @@ fn rmain() -> Result<(), Error> {
159159
// TODO: eventually we should provide the ability to exit at some point
160160
// (gracefully) here, but for now this just runs forever.
161161
if !headless {
162-
println!("Running server on http://{}", addr);
162+
println!("Interactive browsers tests are now available at http://{}", addr);
163+
println!("");
164+
println!("Note that interactive mode is enabled because `NO_HEADLESS`");
165+
println!("is specified in the environment of this process. Once you're");
166+
println!("done with testing you'll need to kill this server with");
167+
println!("Ctrl-C.");
163168
return Ok(srv.run())
164169
}
165170

0 commit comments

Comments
 (0)