From 71a0be16c0bbd6e30983685c2e7fb8abc3b0f177 Mon Sep 17 00:00:00 2001 From: RedYetiDev <38299977+RedYetiDev@users.noreply.github.com> Date: Sat, 17 Aug 2024 18:51:25 -0400 Subject: [PATCH] test_runner: add support for coverage thresholds --- doc/api/cli.md | 42 +++++++++++++++++++++++++++ doc/node.1 | 9 ++++++ lib/internal/test_runner/harness.js | 3 ++ lib/internal/test_runner/test.js | 16 ++++++++++ lib/internal/test_runner/utils.js | 9 ++++++ src/node_options.cc | 19 ++++++++++++ src/node_options.h | 2 ++ test/parallel/test-runner-coverage.js | 19 ++++++++++++ 8 files changed, 119 insertions(+) diff --git a/doc/api/cli.md b/doc/api/cli.md index 0d2e28d22ec511..1fea7ca77a6cd3 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -1084,6 +1084,9 @@ changes: - v18.17.0 pr-url: https://github.com/nodejs/node/pull/47686 description: This option can be used with `--test`. + - version: REPLACEME + pr-url: https://github.com/nodejs/node/pull/54429 + description: A value can now be specified for minimum coverage support. --> When used in conjunction with the `node:test` module, a code coverage report is @@ -1091,6 +1094,8 @@ generated as part of the test runner output. If no tests are run, a coverage report is not generated. See the documentation on [collecting code coverage from tests][] for more details. +When a value is specified, it is treated as [`--test-coverage-min-line`][]. + ### `--experimental-test-module-mocks` + +> 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-min-function` + + + +> 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-min-line` + + + +> 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`