diff --git a/src/command/test.rs b/src/command/test.rs index 2f1a7e402..10e87379d 100644 --- a/src/command/test.rs +++ b/src/command/test.rs @@ -243,7 +243,15 @@ impl Test { fn step_build_tests(&mut self) -> Result<(), Error> { info!("Compiling tests to wasm..."); - build::cargo_build_wasm_tests(&self.crate_path, !self.release, &self.extra_options)?; + // If the user has run `wasm-pack test -- --features "f1" -- test_name`, then we want to only pass through + // `--features "f1"` to `cargo build` + let extra_options = + if let Some(index) = self.extra_options.iter().position(|arg| arg == "--") { + &self.extra_options[..index] + } else { + &self.extra_options + }; + build::cargo_build_wasm_tests(&self.crate_path, !self.release, extra_options)?; info!("Finished compiling tests to wasm."); Ok(()) diff --git a/tests/all/test.rs b/tests/all/test.rs index 70083c9c6..a013818db 100644 --- a/tests/all/test.rs +++ b/tests/all/test.rs @@ -380,13 +380,25 @@ fn extra_options_is_passed_to_cargo_when_building_tests() { fn smoke() { foo::foo(); } + + #[wasm_bindgen_test] + fn fire() { + panic!("This should be filtered from test execution."); + } "#, ) .install_local_wasm_bindgen(); let _lock = fixture.lock(); fixture .wasm_pack() - .args(&["test", "--node", "--", "--no-default-features"]) + .args(&[ + "test", + "--node", + "--", + "--no-default-features", + "--", + "smoke", + ]) .assert() .success(); }