| 84 | |
| 85 | // Add individual test result to an aggregated test result |
| 86 | export const addResult = ( |
| 87 | aggregatedResults: AggregatedResult, |
| 88 | testResult: TestResult, |
| 89 | ): void => { |
| 90 | // `todos` are new as of Jest 24, and not all runners return it. |
| 91 | // Set it to `0` to avoid `NaN` |
| 92 | if (!testResult.numTodoTests) { |
| 93 | testResult.numTodoTests = 0; |
| 94 | } |
| 95 | |
| 96 | aggregatedResults.testResults.push(testResult); |
| 97 | aggregatedResults.numTotalTests += |
| 98 | testResult.numPassingTests + |
| 99 | testResult.numFailingTests + |
| 100 | testResult.numPendingTests + |
| 101 | testResult.numTodoTests; |
| 102 | aggregatedResults.numFailedTests += testResult.numFailingTests; |
| 103 | aggregatedResults.numPassedTests += testResult.numPassingTests; |
| 104 | aggregatedResults.numPendingTests += testResult.numPendingTests; |
| 105 | aggregatedResults.numTodoTests += testResult.numTodoTests; |
| 106 | |
| 107 | if (testResult.testExecError) { |
| 108 | aggregatedResults.numRuntimeErrorTestSuites++; |
| 109 | } |
| 110 | |
| 111 | if (testResult.skipped) { |
| 112 | aggregatedResults.numPendingTestSuites++; |
| 113 | } else if (testResult.numFailingTests > 0 || testResult.testExecError) { |
| 114 | aggregatedResults.numFailedTestSuites++; |
| 115 | } else { |
| 116 | aggregatedResults.numPassedTestSuites++; |
| 117 | } |
| 118 | |
| 119 | // Snapshot data |
| 120 | if (testResult.snapshot.added) { |
| 121 | aggregatedResults.snapshot.filesAdded++; |
| 122 | } |
| 123 | if (testResult.snapshot.fileDeleted) { |
| 124 | aggregatedResults.snapshot.filesRemoved++; |
| 125 | } |
| 126 | if (testResult.snapshot.unmatched) { |
| 127 | aggregatedResults.snapshot.filesUnmatched++; |
| 128 | } |
| 129 | if (testResult.snapshot.updated) { |
| 130 | aggregatedResults.snapshot.filesUpdated++; |
| 131 | } |
| 132 | |
| 133 | aggregatedResults.snapshot.added += testResult.snapshot.added; |
| 134 | aggregatedResults.snapshot.matched += testResult.snapshot.matched; |
| 135 | aggregatedResults.snapshot.unchecked += testResult.snapshot.unchecked; |
| 136 | if ( |
| 137 | testResult.snapshot.uncheckedKeys != null && |
| 138 | testResult.snapshot.uncheckedKeys.length > 0 |
| 139 | ) { |
| 140 | aggregatedResults.snapshot.uncheckedKeysByFile.push({ |
| 141 | filePath: testResult.testFilePath, |
| 142 | keys: testResult.snapshot.uncheckedKeys, |
| 143 | }); |