From ea9a675f56a2ac08bcda70dd20b6c0475f54438b Mon Sep 17 00:00:00 2001 From: Pietro Marchini Date: Tue, 17 Dec 2024 12:10:17 +0100 Subject: [PATCH] test_runner: exclude test files from coverage by default PR-URL: https://github.com/nodejs/node/pull/56060 Reviewed-By: Colin Ihrig Reviewed-By: Matteo Collina Reviewed-By: Moshe Atlow --- doc/api/cli.md | 3 + doc/api/test.md | 7 +- lib/internal/fs/glob.js | 23 ++++ lib/internal/test_runner/coverage.js | 17 ++- lib/internal/test_runner/utils.js | 5 + lib/path.js | 27 +--- .../coverage-default-exclusion/file-test.js | 7 ++ .../coverage-default-exclusion/file.test.mjs | 7 ++ .../coverage-default-exclusion/file.test.ts | 7 ++ .../coverage-default-exclusion/logic-file.js | 9 ++ .../coverage-default-exclusion/test.cjs | 7 ++ .../test/not-matching-test-name.js | 7 ++ .../test-runner/output/lcov_reporter.js | 11 +- ...test-runner-coverage-default-exclusion.mjs | 116 ++++++++++++++++++ .../test-runner-coverage-source-map.js | 6 +- .../test-runner-coverage-thresholds.js | 6 + test/parallel/test-runner-coverage.js | 89 +++++++++++--- test/parallel/test-runner-output.mjs | 29 +++-- 18 files changed, 328 insertions(+), 55 deletions(-) create mode 100644 test/fixtures/test-runner/coverage-default-exclusion/file-test.js create mode 100644 test/fixtures/test-runner/coverage-default-exclusion/file.test.mjs create mode 100644 test/fixtures/test-runner/coverage-default-exclusion/file.test.ts create mode 100644 test/fixtures/test-runner/coverage-default-exclusion/logic-file.js create mode 100644 test/fixtures/test-runner/coverage-default-exclusion/test.cjs create mode 100644 test/fixtures/test-runner/coverage-default-exclusion/test/not-matching-test-name.js create mode 100644 test/parallel/test-runner-coverage-default-exclusion.mjs diff --git a/doc/api/cli.md b/doc/api/cli.md index faade390886e9b..18c16aba1e7604 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -2267,6 +2267,9 @@ This option may be specified multiple times to exclude multiple glob patterns. If both `--test-coverage-exclude` and `--test-coverage-include` are provided, files must meet **both** criteria to be included in the coverage report. +By default all the matching test files are excluded from the coverage report. +Specifying this option will override the default behavior. + ### `--test-coverage-functions=threshold`