From d4310fe9c1d8f3f7d9c08fef2726e0e8dd66f124 Mon Sep 17 00:00:00 2001 From: Aviv Keller <38299977+RedYetiDev@users.noreply.github.com> Date: Fri, 23 Aug 2024 13:02:11 -0400 Subject: [PATCH] test_runner: add support for coverage thresholds Co-Authored-By: Marco Ippolito PR-URL: https://github.com/nodejs/node/pull/54429 Reviewed-By: Matteo Collina Reviewed-By: Paolo Insogna Reviewed-By: Moshe Atlow Reviewed-By: Colin Ihrig Reviewed-By: Marco Ippolito --- doc/api/cli.md | 36 ++++++ doc/node.1 | 9 ++ lib/internal/test_runner/test.js | 21 ++++ lib/internal/test_runner/utils.js | 15 +++ src/node_options.cc | 13 +++ src/node_options.h | 3 + .../test-runner-coverage-thresholds.js | 110 ++++++++++++++++++ 7 files changed, 207 insertions(+) create mode 100644 test/parallel/test-runner-coverage-thresholds.js diff --git a/doc/api/cli.md b/doc/api/cli.md index 33b9e1ce00b9b6..1eaf935ca121f3 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -2218,6 +2218,17 @@ concurrently. If `--experimental-test-isolation` is set to `'none'`, this flag is ignored and concurrency is one. Otherwise, concurrency defaults to `os.availableParallelism() - 1`. +### `--test-coverage-branches=threshold` + + + +> Stability: 1 - Experimental + +Require a minimum percent of covered branches. If code coverage does not reach +the threshold specified, the process will exit with code `1`. + ### `--test-coverage-exclude` + +> Stability: 1 - Experimental + +Require a minimum percent of covered functions. If code coverage does not reach +the threshold specified, the process will exit with code `1`. + ### `--test-coverage-include` + +> Stability: 1 - Experimental + +Require a minimum percent of covered lines. If code coverage does not reach +the threshold specified, the process will exit with code `1`. + ### `--test-force-exit`