Skip to content

Commit 1cba560

Browse files
committed
fix: testMatch not working with negatios
1 parent d16d420 commit 1cba560

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

packages/jest-cli/src/__tests__/search_source.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
{},

packages/jest-cli/src/search_source.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) => {

0 commit comments

Comments
 (0)