Skip to content
Latchkey

wasm-pack test: Run Wasm Tests Headless in CI

wasm-pack test compiles your crate to wasm and runs its wasm-bindgen-test suite in Node.js or a headless browser.

For Rust code that targets the browser, wasm-pack test drives the wasm-bindgen test harness in a real (headless) engine so DOM and JS-interop tests actually execute in CI.

What it does

wasm-pack test builds the crate for wasm and launches the selected environment (Node or a browser via a WebDriver), running functions marked with #[wasm_bindgen_test] and reporting pass/fail.

Common usage

Terminal
wasm-pack test --node
wasm-pack test --headless --chrome
wasm-pack test --headless --firefox
wasm-pack test --headless --chrome -- --features integration

Options

FlagWhat it does
--nodeRun the tests under Node.js
--headlessRun the browser without a UI (required in CI)
--chrome / --firefox / --safariChoose the browser engine
-- <cargo args>Pass extra args to cargo test after --

In CI

Always pass --headless in pipelines; without it the browser tries to open a window and hangs. The matching WebDriver (chromedriver / geckodriver) must be on PATH; GitHub-hosted runners ship Chrome and Firefox, but you still need the driver.

Common errors in CI

"wasm-pack: command not found" means wasm-pack is not installed. "chromedriver ... not found" or "geckodriver not found" means the driver is missing from PATH. "the code did not terminate" with a hang almost always means --headless was omitted. A wasm-bindgen version mismatch surfaces as "schema version mismatch".

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →