Skip to content

Negation does not work with testMatch option #6440

@caseyWebb

Description

@caseyWebb

🐛 Bug Report

The documentation for the testMatch option indicates that any micromatch patterns are valid, however negation does not appear to work.

See the micromatch package for details of the patterns you can specify.

https://facebook.github.io/jest/docs/en/configuration.html#testmatch-array-string

To Reproduce

  • Create two test files, __tests__/test.js and __tests__/test.noop.js. Fill with a placeholder test.
  • Set testMatch in jest config to "testMatch": ["**/__tests__/*.js", "!**/*.noop.js"]
  • Run jest

A minimal repo to repoduce is provided here

Expected behavior

With the steps above, test.noop.js should not be executed, but it is.

Link to repl or repo (highly encouraged)

https://github.com/caseyWebb/jest-negation-bug

(note, to confirm this is valid micromatch, you can run the match.js file in that repo (node match.js)

Run npx envinfo --preset jest

Paste the results here:

npx: installed 1 in 0.846s
(node:22743) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '1' of null
    at a.run.then.e (/home/casey/.npm/_npx/22743/lib/node_modules/envinfo/dist/cli.js:2:96634)
    at <anonymous>
(node:22743) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:22743) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

...not much help (fyi, this is on Linux).

Jest is 23.1.0
Node is 9.11.1

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