diff --git a/cli/tools/coverage/mod.rs b/cli/tools/coverage/mod.rs index e5bd3ae2e2..b076895700 100644 --- a/cli/tools/coverage/mod.rs +++ b/cli/tools/coverage/mod.rs @@ -485,6 +485,9 @@ pub async fn cover_files( coverage_flags.exclude, npm_resolver.as_ref(), ); + if script_coverages.is_empty() { + return Err(generic_error("No covered files included in the report")); + } let proc_coverages: Vec<_> = script_coverages .into_iter() diff --git a/tests/specs/coverage/no_files_after_filter/__test__.jsonc b/tests/specs/coverage/no_files_after_filter/__test__.jsonc new file mode 100644 index 0000000000..e8aa477a89 --- /dev/null +++ b/tests/specs/coverage/no_files_after_filter/__test__.jsonc @@ -0,0 +1,15 @@ +{ + "tempDir": true, + "steps": [ + { + "args": "test --coverage test.ts", + "output": "test_coverage.out", + "exitCode": 0 + }, + { + "args": "coverage ./coverage", + "output": "no_files_in_report.out", + "exitCode": 1 + } + ] +} diff --git a/tests/specs/coverage/no_files_after_filter/no_files_in_report.out b/tests/specs/coverage/no_files_after_filter/no_files_in_report.out new file mode 100644 index 0000000000..c9ba7af951 --- /dev/null +++ b/tests/specs/coverage/no_files_after_filter/no_files_in_report.out @@ -0,0 +1 @@ +error: No covered files included in the report diff --git a/tests/specs/coverage/no_files_after_filter/test.ts b/tests/specs/coverage/no_files_after_filter/test.ts new file mode 100644 index 0000000000..03818ae8d4 --- /dev/null +++ b/tests/specs/coverage/no_files_after_filter/test.ts @@ -0,0 +1 @@ +Deno.test("test", () => {}); diff --git a/tests/specs/coverage/no_files_after_filter/test_coverage.out b/tests/specs/coverage/no_files_after_filter/test_coverage.out new file mode 100644 index 0000000000..3c598f62e1 --- /dev/null +++ b/tests/specs/coverage/no_files_after_filter/test_coverage.out @@ -0,0 +1,6 @@ +Check [WILDCARD]/test.ts +running 1 test from ./test.ts +test ... ok ([WILDCARD]) + +ok | 1 passed | 0 failed ([WILDCARD]) +