From ab67b4c645dc34619e09c2f9f36c18122b11a307 Mon Sep 17 00:00:00 2001 From: Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> Date: Fri, 15 Mar 2024 20:58:57 -0700 Subject: 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. --- cli/tools/coverage/mod.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'cli/tools/coverage/mod.rs') diff --git a/cli/tools/coverage/mod.rs b/cli/tools/coverage/mod.rs index e5bd3ae2e..b07689570 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() -- cgit v1.2.3