mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-18 23:41:24 +00:00
Add support for headless testing
This commit adds support to the `wasm-bindgen-test-runner` binary to perform headless testing via browsers. The previous commit introduced a local server to serve up files and run tests in a browser, and this commit adds support for executing that in an automated fashion. The general idea here is that each browser has a binary that implements the WebDriver specification. These binaries (typically `foodriver` for the browser "Foo") are interfaced with using HTTP and JSON messages. The implementation was simple enough and the crates.io support was lacking enough that a small implementation of the WebDriver protocol was added directly to this crate. Currently Firefox (`geckodriver`), Chrome (`chromedriver`), and Safari (`safaridriver`) are supported for running tests. The test harness will recognize env vars like `GECKODRIVER=foo` to specifically use one or otherwise detects the first driver in `PATH`. Eventually we may wish to automatically download a driver if one isn't found, but that isn't implemented yet. Headless testing is turned on with the `CI=1` env var currently to be amenable with things like Travis and AppVeyor, but this may wish to grow an explicit option to run headless tests in the future.
This commit is contained in:
@ -20,6 +20,31 @@ macro_rules! console_log {
|
||||
)
|
||||
}
|
||||
|
||||
/// A macro used to configured how this test is executed by the
|
||||
/// `wasm-bindgen-test-runner` harness.
|
||||
///
|
||||
/// This macro is invoked as:
|
||||
///
|
||||
/// wasm_bindgen_test_configure!(foo bar baz);
|
||||
///
|
||||
/// where all of `foo`, `bar`, and `baz`, would be recognized options to this
|
||||
/// macro. The currently known options to this macro are:
|
||||
///
|
||||
/// * `run_in_browser` - requires that this test is run in a browser rather than
|
||||
/// node.js, which is the default for executing tests.
|
||||
///
|
||||
/// This macro may be invoked at most one time per test suite.
|
||||
#[macro_export]
|
||||
macro_rules! wasm_bindgen_test_configure {
|
||||
(run_in_browser $($others:tt)*) => (
|
||||
#[link_section = "__wasm_bindgen_test_unstable"]
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub static __WBG_TEST_RUN_IN_BROWSER: [u8; 1] = [0x01];
|
||||
wasm_bindgen_test_configure!($($others)*);
|
||||
);
|
||||
() => ()
|
||||
}
|
||||
|
||||
#[path = "rt/mod.rs"]
|
||||
#[doc(hidden)]
|
||||
pub mod __rt;
|
||||
|
Reference in New Issue
Block a user