Skip to content

[Bug]: Unable to run a test from whitelisted "node_modules" #11781

@kettanaito

Description

@kettanaito

Version

27.0.6

Steps to reproduce

  1. Clone the repo at https://github.com/kettanaito/jest-nm-issue
  2. yarn install
  3. yarn test

Expected behavior

Jest detects the node_modules/__test/example.test.js file and runs it.
The file matches the testMatch pattern, which you can confirm by clicking on that pattern in the terminal and being navigated to the correct existing directory (tested in VS Code).

Actual behavior

$ jest
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In /Users/kettanaito/Projects/contrib/jest-nm-issue
  2 files checked.
  testMatch: /Users/kettanaito/Projects/contrib/jest-nm-issue/node_modules/__test/*.test.js - 0 matches
  testPathIgnorePatterns: not_node_modules - 2 matches
  testRegex:  - 0 matches
Pattern:  - 0 matches
  • 0 matches next to the correct pattern pointing to an existing directory under node_modules is not expected.

Additional context

I distribute a test suite as a node module because it acts as a specification for multiple projects. I wish to run that test suite from the node_modules where it's installed.

Regardless of my setup, it's confusing that Jest seems to ignore anything as long as it includes "node_modules" even if I've explicitly whitelisted a certain directory in it.

Environment

System:
  OS: macOS 11.5.1
  CPU: (16) x64 Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
Binaries:
  Node: 12.18.2 - /usr/local/bin/node
  Yarn: 1.22.10 - /usr/local/bin/yarn
  npm: 6.14.5 - /usr/local/bin/npm
npmPackages:
  jest: ^27.0.6 => 27.0.6

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions