Skip to content

🚀 Feature: Change default value for --ignore to **/node_modules, **/.git #5131

Open
@Danielku15

Description

Feature Request Checklist

Overview

Looking at the current behavior of Mocha there is an inconsistency between normal execution and watch execution due to different defaults in --ignore and --watch-ignore.

I think many devs will agree that picking up data from the node_modules folder is not in their interest when maintaining any project and running tests.

Additionally the node_modules folder might live in a subfolder (mono repos) but still is subject of being ignored. The current pattern only ignores node_modules on the level of the mocharc config file.

Suggested Solution

  1. The default values for the two options should be set to the same value.
  2. The default patterns should also ignore these folders if they are in subfolders.

Hence the new default for both options should be similar to: ['**/node_modules/', '**/.git/']

Alternatives

If this is the intended behavior and has a reasoning, this reasoning should be documented on the website.

Additional Info

When using NPM workspaces (common in mono-repos) there will be symlinks from node_modules to the directories of the packages. https://docs.npmjs.com/cli/v10/using-npm/workspaces
Running Mocha with --reporter=json then shows that rather the tests in the node_modules are picked up than the real working directory.

image

This can lead to further problems when processing the test reports or in case external tooling relies on these paths.

The problem became visible while working on a VS Code Extension and tests from node_modules were listed.

CoderLine/mocha-vscode#1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    semver-majorimplementation requires increase of "major" version number; "breaking changes"status: accepting prsMocha can use your help with this one!type: featureenhancement proposal

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions