Skip to content

Commit b7828e9

Browse files
authored
chore: remove a couple filters and move to reduce (#14506)
1 parent 4feb4ba commit b7828e9

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

packages/jest-core/src/FailedTestsCache.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,26 @@ export default class FailedTestsCache {
2222
}
2323

2424
setTestResults(testResults: Array<TestResult>): void {
25-
this._enabledTestsMap = (testResults || [])
26-
.filter(testResult => testResult.numFailingTests)
27-
.reduce<TestMap>((suiteMap, testResult) => {
28-
suiteMap[testResult.testFilePath] = testResult.testResults
29-
.filter(test => test.status === 'failed')
30-
.reduce<{[name: string]: true}>((testMap, test) => {
31-
testMap[test.fullName] = true;
25+
this._enabledTestsMap = (testResults || []).reduce<TestMap>(
26+
(suiteMap, testResult) => {
27+
if (!testResult.numFailingTests) {
28+
return suiteMap;
29+
}
30+
31+
suiteMap[testResult.testFilePath] = testResult.testResults.reduce<{
32+
[name: string]: true;
33+
}>((testMap, test) => {
34+
if (test.status !== 'failed') {
3235
return testMap;
33-
}, {});
36+
}
37+
38+
testMap[test.fullName] = true;
39+
return testMap;
40+
}, {});
3441
return suiteMap;
35-
}, {});
42+
},
43+
{},
44+
);
3645

3746
this._enabledTestsMap = Object.freeze(this._enabledTestsMap);
3847
}

0 commit comments

Comments
 (0)