Skip to content

Commit 0a16c5d

Browse files
authored
fix: testMatch not working with negations (#6648)
1 parent af036fa commit 0a16c5d

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- `[jest-snapshot` Mark snapshots as obsolete when moved to an inline snapshot ([#6773](https://github.com/facebook/jest/pull/6773))
1010
- `[jest-config]` Fix `--coverage` with `--findRelatedTests` overwriting `collectCoverageFrom` options ([#6736](https://github.com/facebook/jest/pull/6736))
1111
- `[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))
12+
- `[jest-cli]` Fix `testMatch` not working with negations ([#6648](https://github.com/facebook/jest/pull/6648))
1213

1314
## 23.4.2
1415

packages/jest-cli/src/SearchSource.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ const globsToMatcher = (globs: ?Array<Glob>) => {
4747
return () => true;
4848
}
4949

50-
const matchers = globs.map(each => micromatch.matcher(each, {dot: true}));
51-
return path => matchers.some(each => each(path));
50+
return path => micromatch([path], globs, {dot: true}).length > 0;
5251
};
5352

5453
const regexToMatcher = (testRegex: string) => {

packages/jest-cli/src/__tests__/SearchSource.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ describe('SearchSource', () => {
135135
moduleFileExtensions: ['js', 'jsx', 'txt'],
136136
name,
137137
rootDir,
138-
testMatch: ['**/not-really-a-test.txt'],
138+
testMatch: ['**/not-really-a-test.txt', '!**/do-not-match-me.txt'],
139139
testRegex: '',
140140
},
141141
{},

0 commit comments

Comments
 (0)