From a4939437d19cac0015c2c16790846cfe38fdfd2d Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Mon, 18 Nov 2024 02:08:03 -0800 Subject: [PATCH] Exit code non-zero when no tests run --- src/cli/test_command.zig | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/cli/test_command.zig b/src/cli/test_command.zig index 451f1e2a52..929c122106 100644 --- a/src/cli/test_command.zig +++ b/src/cli/test_command.zig @@ -1102,10 +1102,17 @@ pub const TestCommand = struct { } } - if (reporter.summary.fail > 0 or (coverage.enabled and coverage.fractions.failing and coverage.fail_on_low_coverage)) { + if ( + // Fail when no tests were run. + (reporter.summary.pass + reporter.summary.skip + reporter.summary.todo) == 0 or + // Fail when there are unhandled errors between tests + reporter.jest.unhandled_errors_between_tests > 0 or + // Fail when there are test failures + reporter.summary.fail > 0 or + // Fail when coverage is enabled and the coverage is too low + (coverage.enabled and coverage.fractions.failing and coverage.fail_on_low_coverage)) + { Global.exit(1); - } else if (reporter.jest.unhandled_errors_between_tests > 0) { - Global.exit(reporter.jest.unhandled_errors_between_tests); } }