|
5 | 5 | * LICENSE file in the root directory of this source tree. |
6 | 6 | */ |
7 | 7 |
|
8 | | -import {Config, TestResult} from '@jest/types'; |
9 | | - |
| 8 | +import {Config} from '@jest/types'; |
| 9 | +import {AssertionResult, Status, TestResult} from '@jest/test-result'; |
10 | 10 | import {extractExpectedAssertionsErrors, getState, setState} from 'expect'; |
11 | 11 | import {formatExecError, formatResultsErrors} from 'jest-message-util'; |
12 | 12 | import { |
@@ -127,51 +127,51 @@ export const runAndTransformResultsToJestFormat = async ({ |
127 | 127 | config: Config.ProjectConfig; |
128 | 128 | globalConfig: Config.GlobalConfig; |
129 | 129 | testPath: string; |
130 | | -}): Promise<TestResult.TestResult> => { |
| 130 | +}): Promise<TestResult> => { |
131 | 131 | const runResult: RunResult = await run(); |
132 | 132 |
|
133 | 133 | let numFailingTests = 0; |
134 | 134 | let numPassingTests = 0; |
135 | 135 | let numPendingTests = 0; |
136 | 136 | let numTodoTests = 0; |
137 | 137 |
|
138 | | - const assertionResults: Array< |
139 | | - TestResult.AssertionResult |
140 | | - > = runResult.testResults.map(testResult => { |
141 | | - let status: TestResult.Status; |
142 | | - if (testResult.status === 'skip') { |
143 | | - status = 'pending'; |
144 | | - numPendingTests += 1; |
145 | | - } else if (testResult.status === 'todo') { |
146 | | - status = 'todo'; |
147 | | - numTodoTests += 1; |
148 | | - } else if (testResult.errors.length) { |
149 | | - status = 'failed'; |
150 | | - numFailingTests += 1; |
151 | | - } else { |
152 | | - status = 'passed'; |
153 | | - numPassingTests += 1; |
154 | | - } |
| 138 | + const assertionResults: Array<AssertionResult> = runResult.testResults.map( |
| 139 | + testResult => { |
| 140 | + let status: Status; |
| 141 | + if (testResult.status === 'skip') { |
| 142 | + status = 'pending'; |
| 143 | + numPendingTests += 1; |
| 144 | + } else if (testResult.status === 'todo') { |
| 145 | + status = 'todo'; |
| 146 | + numTodoTests += 1; |
| 147 | + } else if (testResult.errors.length) { |
| 148 | + status = 'failed'; |
| 149 | + numFailingTests += 1; |
| 150 | + } else { |
| 151 | + status = 'passed'; |
| 152 | + numPassingTests += 1; |
| 153 | + } |
155 | 154 |
|
156 | | - const ancestorTitles = testResult.testPath.filter( |
157 | | - name => name !== ROOT_DESCRIBE_BLOCK_NAME, |
158 | | - ); |
159 | | - const title = ancestorTitles.pop(); |
| 155 | + const ancestorTitles = testResult.testPath.filter( |
| 156 | + name => name !== ROOT_DESCRIBE_BLOCK_NAME, |
| 157 | + ); |
| 158 | + const title = ancestorTitles.pop(); |
160 | 159 |
|
161 | | - return { |
162 | | - ancestorTitles, |
163 | | - duration: testResult.duration, |
164 | | - failureMessages: testResult.errors, |
165 | | - fullName: title |
166 | | - ? ancestorTitles.concat(title).join(' ') |
167 | | - : ancestorTitles.join(' '), |
168 | | - invocations: testResult.invocations, |
169 | | - location: testResult.location, |
170 | | - numPassingAsserts: 0, |
171 | | - status, |
172 | | - title: testResult.testPath[testResult.testPath.length - 1], |
173 | | - }; |
174 | | - }); |
| 160 | + return { |
| 161 | + ancestorTitles, |
| 162 | + duration: testResult.duration, |
| 163 | + failureMessages: testResult.errors, |
| 164 | + fullName: title |
| 165 | + ? ancestorTitles.concat(title).join(' ') |
| 166 | + : ancestorTitles.join(' '), |
| 167 | + invocations: testResult.invocations, |
| 168 | + location: testResult.location, |
| 169 | + numPassingAsserts: 0, |
| 170 | + status, |
| 171 | + title: testResult.testPath[testResult.testPath.length - 1], |
| 172 | + }; |
| 173 | + }, |
| 174 | + ); |
175 | 175 |
|
176 | 176 | let failureMessage = formatResultsErrors( |
177 | 177 | assertionResults, |
|
0 commit comments