diff --git a/CHANGELOG.md b/CHANGELOG.md index efd456d7db1c..a6b775c28300 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - `[jest-snapshot` Mark snapshots as obsolete when moved to an inline snapshot ([#6773](https://github.com/facebook/jest/pull/6773)) - `[jest-config]` Fix `--coverage` with `--findRelatedTests` overwriting `collectCoverageFrom` options ([#6736](https://github.com/facebook/jest/pull/6736)) - `[jest-config]` Update default config for testURL from 'about:blank' to 'http://localhost' to address latest JSDOM security warning. ([#6792](https://github.com/facebook/jest/pull/6792)) +- `[jest-cli]` Fix `testMatch` not working with negations ([#6648](https://github.com/facebook/jest/pull/6648)) ## 23.4.2 diff --git a/packages/jest-cli/src/SearchSource.js b/packages/jest-cli/src/SearchSource.js index 7ea662a8c9bd..57caf26e8506 100644 --- a/packages/jest-cli/src/SearchSource.js +++ b/packages/jest-cli/src/SearchSource.js @@ -47,8 +47,7 @@ const globsToMatcher = (globs: ?Array) => { return () => true; } - const matchers = globs.map(each => micromatch.matcher(each, {dot: true})); - return path => matchers.some(each => each(path)); + return path => micromatch([path], globs, {dot: true}).length > 0; }; const regexToMatcher = (testRegex: string) => { diff --git a/packages/jest-cli/src/__tests__/SearchSource.test.js b/packages/jest-cli/src/__tests__/SearchSource.test.js index 18b51e287bb1..d513df33d2e4 100644 --- a/packages/jest-cli/src/__tests__/SearchSource.test.js +++ b/packages/jest-cli/src/__tests__/SearchSource.test.js @@ -135,7 +135,7 @@ describe('SearchSource', () => { moduleFileExtensions: ['js', 'jsx', 'txt'], name, rootDir, - testMatch: ['**/not-really-a-test.txt'], + testMatch: ['**/not-really-a-test.txt', '!**/do-not-match-me.txt'], testRegex: '', }, {},