1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', {
|
4 | value: true
|
5 | });
|
6 | exports.default = formatTestResults;
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | const formatTestResult = (testResult, codeCoverageFormatter, reporter) => {
|
15 | if (testResult.testExecError) {
|
16 | const now = Date.now();
|
17 | return {
|
18 | assertionResults: testResult.testResults,
|
19 | coverage: {},
|
20 | endTime: now,
|
21 | message: testResult.failureMessage ?? testResult.testExecError.message,
|
22 | name: testResult.testFilePath,
|
23 | startTime: now,
|
24 | status: 'failed',
|
25 | summary: ''
|
26 | };
|
27 | }
|
28 | if (testResult.skipped) {
|
29 | const now = Date.now();
|
30 | return {
|
31 | assertionResults: testResult.testResults,
|
32 | coverage: {},
|
33 | endTime: now,
|
34 | message: testResult.failureMessage ?? '',
|
35 | name: testResult.testFilePath,
|
36 | startTime: now,
|
37 | status: 'skipped',
|
38 | summary: ''
|
39 | };
|
40 | }
|
41 | const allTestsExecuted = testResult.numPendingTests === 0;
|
42 | const allTestsPassed = testResult.numFailingTests === 0;
|
43 | return {
|
44 | assertionResults: testResult.testResults,
|
45 | coverage:
|
46 | codeCoverageFormatter != null
|
47 | ? codeCoverageFormatter(testResult.coverage, reporter)
|
48 | : testResult.coverage,
|
49 | endTime: testResult.perfStats.end,
|
50 | message: testResult.failureMessage ?? '',
|
51 | name: testResult.testFilePath,
|
52 | startTime: testResult.perfStats.start,
|
53 | status: allTestsPassed
|
54 | ? allTestsExecuted
|
55 | ? 'passed'
|
56 | : 'focused'
|
57 | : 'failed',
|
58 | summary: ''
|
59 | };
|
60 | };
|
61 | function formatTestResults(results, codeCoverageFormatter, reporter) {
|
62 | const testResults = results.testResults.map(testResult =>
|
63 | formatTestResult(testResult, codeCoverageFormatter, reporter)
|
64 | );
|
65 | return {
|
66 | ...results,
|
67 | testResults
|
68 | };
|
69 | }
|