diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2024-05-28 23:01:32 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-28 23:01:32 +0900 |
commit | 8b5089e41fc9385eb2a1d964517a2aa9726c2794 (patch) | |
tree | c9c89d8eea81867a470ee3af27d60cd7d14e35dd | |
parent | 9aa593cd5d4024890e36af7842f1eb4b4c3bd544 (diff) |
fix(coverage): do not generate script coverage with empty url (#24007)
closes #24004
-rw-r--r-- | cli/tools/coverage/mod.rs | 4 | ||||
-rw-r--r-- | tests/testdata/coverage/multisource/test.ts | 4 |
2 files changed, 7 insertions, 1 deletions
diff --git a/cli/tools/coverage/mod.rs b/cli/tools/coverage/mod.rs index 699d4a583..030bf425e 100644 --- a/cli/tools/coverage/mod.rs +++ b/cli/tools/coverage/mod.rs @@ -68,12 +68,14 @@ impl crate::worker::CoverageCollector for CoverageCollector { let script_coverages = self.take_precise_coverage().await?.result; for script_coverage in script_coverages { - // Filter out internal and http/https JS files from being included in coverage reports + // Filter out internal and http/https JS files and eval'd scripts + // from being included in coverage reports if script_coverage.url.starts_with("ext:") || script_coverage.url.starts_with("[ext:") || script_coverage.url.starts_with("http:") || script_coverage.url.starts_with("https:") || script_coverage.url.starts_with("node:") + || script_coverage.url.is_empty() { continue; } diff --git a/tests/testdata/coverage/multisource/test.ts b/tests/testdata/coverage/multisource/test.ts index 350421177..766798c64 100644 --- a/tests/testdata/coverage/multisource/test.ts +++ b/tests/testdata/coverage/multisource/test.ts @@ -20,3 +20,7 @@ Deno.test("qux", () => { Deno.test("quux", () => { quux(false); }); + +// Function constructor or eval function generates a new script source internally. +// This call ensures that the coverage data for the eval script source is not generated. +eval("console.log(1)"); |