Skip to content

Commit

Permalink
fix(coverage): do not generate script coverage with empty url (denola…
Browse files Browse the repository at this point in the history
  • Loading branch information
kt3k authored May 28, 2024
1 parent 9aa593c commit 8b5089e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cli/tools/coverage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions tests/testdata/coverage/multisource/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)");

0 comments on commit 8b5089e

Please sign in to comment.