Skip to content

test_runner: match dotfiles in default coverage exclude#63401

Open
semimikoh wants to merge 2 commits into
nodejs:mainfrom
semimikoh:test_runner/coverage-dotfile-exclude
Open

test_runner: match dotfiles in default coverage exclude#63401
semimikoh wants to merge 2 commits into
nodejs:mainfrom
semimikoh:test_runner/coverage-dotfile-exclude

Conversation

@semimikoh
Copy link
Copy Markdown
Contributor

@semimikoh semimikoh commented May 18, 2026

The default coverage exclude patterns ... (본문)

Fixes: #63397

Problem

node --experimental-test-coverage includes dotfile test files (e.g. test/.foo.cjs) in the coverage report even though the default exclude patterns are intended to drop everything under test/. Non-dotfile siblings are correctly excluded.

This is caused by matchGlobPattern calling minimatch without dot: true; minimatch's default behavior is to not match dot-prefixed entries unless the pattern itself starts with a dot.

Reported in #63397.

Fix

  • lib/internal/fs/glob.js: extend matchGlobPattern with an optional options argument forwarded to minimatch. Fixed options (nocase, windowsPathsNoEscape, etc.) still take precedence so callers cannot accidentally override them.
  • lib/internal/test_runner/coverage.js: route the four exclude/include match calls through a small helper that passes { dot: true }. Applied to both exclude and include for consistency.

Test

Added a new scenario to test-runner-coverage-default-exclusion.mjs that runs test/.dotfile.cjs explicitly and asserts the dotfile does not appear in the coverage report under the default exclude patterns. The new fixture test/.dotfile.cjs exercises the same logic-file.js as the existing fixtures.

Fixes: #63397

The default coverage exclude patterns ... (본문)

Fixes: nodejs#63397
Signed-off-by: semimikoh <ejffjeosms@gmail.com>
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-bot nodejs-github-bot added fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem. labels May 18, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.07%. Comparing base (1f371fc) to head (c241614).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #63401      +/-   ##
==========================================
+ Coverage   90.05%   90.07%   +0.02%     
==========================================
  Files         714      714              
  Lines      225704   225706       +2     
  Branches    42714    42729      +15     
==========================================
+ Hits       203250   203302      +52     
+ Misses      14225    14188      -37     
+ Partials     8229     8216      -13     
Files with missing lines Coverage Δ
lib/internal/test_runner/utils.js 65.32% <100.00%> (+0.08%) ⬆️

... and 27 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Signed-off-by: semimikoh <ejffjeosms@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default behavior of --test-coverage-exclude globbing does NOT apply to "dotfiles" like .mytest.cjs (common globbing oversight)

2 participants