Skip to content

Commit

Permalink
update _filterTestPathsWithStats condition
Browse files Browse the repository at this point in the history
We only want to _filterTestPathsWithStats if testPathPattern was
explicitly passed as an argument. The issue is that it's not possible to
simply null check globalConfig.testPathPattern to determine if it was
explicity passed becase that field gets populated with values passed to
findRelatedTests also. This approach compares the values in
globalConfig.testPathPattern to the values in globalConfig.nonFlagArgs
and if it is a 1 to 1 match it is assumed that testPathPattern was not
explicity passed as an argument.
  • Loading branch information
Mack Solomon committed Apr 12, 2019
1 parent 5eddcbd commit d83b4c6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/jest-core/src/SearchSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,17 @@ export default class SearchSource {
paths,
globalConfig.collectCoverage,
);
if (globalConfig.testPathPattern !== null) {
if (
globalConfig.testPathPattern
.split('|')
.every(f => globalConfig.nonFlagArgs.includes(f))
) {
return relatedTests;
} else {
return this._filterTestPathsWithStats(
relatedTests.tests,
globalConfig.testPathPattern,
);
} else {
return relatedTests;
}
} else if (globalConfig.testPathPattern != null) {
return this.findMatchingTests(globalConfig.testPathPattern);
Expand Down

0 comments on commit d83b4c6

Please sign in to comment.