summaryrefslogtreecommitdiff
path: root/tests/specs/coverage
diff options
context:
space:
mode:
authorNathan Whitaker <17734409+nathanwhit@users.noreply.github.com>2024-03-15 20:58:57 -0700
committerGitHub <noreply@github.com>2024-03-15 20:58:57 -0700
commitab67b4c645dc34619e09c2f9f36c18122b11a307 (patch)
treec35ad60b1fbe05218c9e22e5ad64f7b04f9ed2db /tests/specs/coverage
parent92576fdcfd3e32dce63b533ab20d4974136b097d (diff)
fix(coverage): Error if no files are included in the report (#22952)
Fixes #22941. In that case, the only file with coverage was the `test.ts` file. The coverage reporter filters out test files before compiling its report, so after filtering we were left with an empty set of files. Later on it's assumed that there is at least 1 file to be reported on, and we panic. Instead of panicking, just issue an error after filtering.
Diffstat (limited to 'tests/specs/coverage')
-rw-r--r--tests/specs/coverage/no_files_after_filter/__test__.jsonc15
-rw-r--r--tests/specs/coverage/no_files_after_filter/no_files_in_report.out1
-rw-r--r--tests/specs/coverage/no_files_after_filter/test.ts1
-rw-r--r--tests/specs/coverage/no_files_after_filter/test_coverage.out6
4 files changed, 23 insertions, 0 deletions
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 000000000..e8aa477a8
--- /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 000000000..c9ba7af95
--- /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 000000000..03818ae8d
--- /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 000000000..3c598f62e
--- /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])
+