diff --git a/crates/cli/tests/reference.rs b/crates/cli/tests/reference.rs index 190df67b541..55697231071 100644 --- a/crates/cli/tests/reference.rs +++ b/crates/cli/tests/reference.rs @@ -52,6 +52,15 @@ //! // FLAGS: --target=web //! // FLAGS: --target=nodejs //! ``` +//! +//! ## Testing only types +//! +//! In some cases, we are only interested in testing the generated `.d.ts` file. +//! In this case, add a comment at the top of the test file: +//! +//! ```rust +//! // TYPES ONLY +//! ``` use anyhow::{bail, Result}; use assert_cmd::prelude::*; @@ -119,6 +128,8 @@ fn runtest(test: &Path) -> Result<()> { let root = repo_root(); let root = root.display(); + let types_only = contents.contains("// TYPES ONLY"); + // parse target declarations let mut all_flags: Vec<_> = contents .lines() @@ -215,7 +226,7 @@ fn runtest(test: &Path) -> Result<()> { _ => "reference_test.js", }; - if !contents.contains("async") { + if !types_only { let js = fs::read_to_string(out_dir.join(main_js_file))?; assert_same(&js, &test.with_extension("js"))?; let wat = sanitize_wasm(&out_dir.join("reference_test_bg.wasm"))?; diff --git a/crates/cli/tests/reference/async-number.rs b/crates/cli/tests/reference/async-number.rs index 2948c43667d..4654452b707 100644 --- a/crates/cli/tests/reference/async-number.rs +++ b/crates/cli/tests/reference/async-number.rs @@ -1,3 +1,5 @@ +// TYPES ONLY + use wasm_bindgen::prelude::*; #[wasm_bindgen] diff --git a/crates/cli/tests/reference/async-void.rs b/crates/cli/tests/reference/async-void.rs index 73f4a0ff586..60bfa1d1a59 100644 --- a/crates/cli/tests/reference/async-void.rs +++ b/crates/cli/tests/reference/async-void.rs @@ -1,3 +1,5 @@ +// TYPES ONLY + use wasm_bindgen::prelude::*; #[wasm_bindgen]