Skip to content

test_runner: match dotfiles in default coverage exclude#63401

Open
semimikoh wants to merge 1 commit into
nodejs:mainfrom
semimikoh:test_runner/coverage-dotfile-exclude
Open

test_runner: match dotfiles in default coverage exclude#63401
semimikoh wants to merge 1 commit 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
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