Skip to content

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

@DavidAnson

Description

@DavidAnson

Version

24.15.0

Platform

macOS

Subsystem

No response

What steps will reproduce the bug?

Run --experimental-test-coverage on a repo with test file names in the test directory beginning with a .. They will be INCLUDED in the coverage summary report while test files next to them without a leading . will not.

How often does it reproduce? Is there a required condition?

100%

What is the expected behavior? Why is that the expected behavior?

All files under test should be excluded by default - this is clearly the intent of the Node.js implementation.

What do you see instead?

"dotfiles" are included.

Additional information

This can presumably be fixed by setting the dot option to true in the call to minimatch here: https://github.com/nodejs/node/blob/v24.x/lib/internal/fs/glob.js#L784-L797

The observed (undesirable) behavior is documented by that project here: https://github.com/isaacs/minimatch#dot

The relevant default globs for Node are found here: https://github.com/nodejs/node/blob/v24.x/lib/internal/test_runner/utils.js#L62-L67

I have confirmed the following produces intended behavior on my machine: --test-coverage-exclude='test/**/{*,.*}'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions