summaryrefslogtreecommitdiff
path: root/cli/tools/coverage/mod.rs
diff options
context:
space:
mode:
authorYoshiya Hinosawa <stibium121@gmail.com>2024-09-20 15:04:22 +0900
committerGitHub <noreply@github.com>2024-09-20 15:04:22 +0900
commit66fb81ea8581bc7f485c99423c307c8fa548b2fe (patch)
tree71be94cdb830bd03fd90008c1e58b867f5f3fd62 /cli/tools/coverage/mod.rs
parenta01dce3a25e0bf671c6c21bd6ff57861be613087 (diff)
fix(coverage): ignore urls from doc testing (#25736)
Diffstat (limited to 'cli/tools/coverage/mod.rs')
-rw-r--r--cli/tools/coverage/mod.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/cli/tools/coverage/mod.rs b/cli/tools/coverage/mod.rs
index f88b3bc64..260c0c842 100644
--- a/cli/tools/coverage/mod.rs
+++ b/cli/tools/coverage/mod.rs
@@ -452,6 +452,11 @@ fn filter_coverages(
let exclude: Vec<Regex> =
exclude.iter().map(|e| Regex::new(e).unwrap()).collect();
+ // Matches virtual file paths for doc testing
+ // e.g. file:///path/to/mod.ts$23-29.ts
+ let doc_test_re =
+ Regex::new(r"\$\d+-\d+\.(js|mjs|cjs|jsx|ts|mts|cts|tsx)$").unwrap();
+
coverages
.into_iter()
.filter(|e| {
@@ -460,6 +465,7 @@ fn filter_coverages(
|| e.url.ends_with("$deno$test.js")
|| e.url.ends_with(".snap")
|| is_supported_test_path(Path::new(e.url.as_str()))
+ || doc_test_re.is_match(e.url.as_str())
|| Url::parse(&e.url)
.ok()
.map(|url| npm_resolver.in_npm_package(&url))