Skip to content

Commit c6ccacd

Browse files
committed
Added type casting to tests and missing  type
1 parent fd93b8c commit c6ccacd

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

packages/jest-test-result/src/__tests__/formatTestResults.test.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,24 @@
66
*/
77

88
import formatTestResults from '../formatTestResults';
9-
import type {AggregatedResult} from '../types';
9+
import type {AggregatedResult, AssertionResult} from '../types';
1010

1111
describe('formatTestResults', () => {
1212
const assertion = {
1313
fullName: 'TestedModule#aMethod when some condition is met returns true',
1414
status: 'passed',
1515
title: 'returns true',
16-
};
16+
} as AssertionResult;
1717

18-
const results: AggregatedResult = {
18+
const results = {
1919
testResults: [
2020
{
2121
numFailingTests: 0,
2222
perfStats: {end: 2, runtime: 1, slow: false, start: 1},
23-
// @ts-expect-error
2423
testResults: [assertion],
2524
},
2625
],
27-
};
26+
} as AggregatedResult;
2827

2928
it('includes test full name', () => {
3029
const result = formatTestResults(results, undefined, null);
@@ -37,21 +36,20 @@ describe('formatTestResults', () => {
3736
fullName: 'Pending test',
3837
status: 'pending',
3938
title: 'is still pending',
40-
};
39+
} as AssertionResult;
4140

42-
const skippedResults: AggregatedResult = {
41+
const skippedResults = {
4342
testResults: [
4443
{
4544
numFailingTests: 0,
4645
numPassingTests: 0,
4746
numPendingTests: 2,
4847
numTodoTests: 2,
4948
perfStats: {end: 2, runtime: 1, slow: false, start: 1},
50-
// @ts-expect-error
5149
testResults: [skippedAssertion],
5250
},
5351
],
54-
};
52+
} as AggregatedResult;
5553

5654
it('should mark result status to skipped', () => {
5755
const result = formatTestResults(skippedResults, undefined, null);
@@ -64,21 +62,20 @@ describe('formatTestResults', () => {
6462
fullName: 'Focused test',
6563
status: 'focused',
6664
title: 'focused test',
67-
};
65+
} as AssertionResult;
6866

69-
const focusedResults: AggregatedResult = {
67+
const focusedResults = {
7068
testResults: [
7169
{
7270
numFailingTests: 0,
7371
numPassingTests: 1,
7472
numPendingTests: 1,
7573
numTodoTests: 2,
7674
perfStats: {end: 2, runtime: 1, slow: false, start: 1},
77-
// @ts-expect-error
7875
testResults: [focusedAssertion],
7976
},
8077
],
81-
};
78+
} as AggregatedResult;
8279

8380
it('should mark result status to focused', () => {
8481
const result = formatTestResults(focusedResults, undefined, null);

packages/jest-types/src/TestResult.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
type Status = 'passed' | 'failed' | 'skipped' | 'pending' | 'todo' | 'disabled';
8+
type Status =
9+
| 'passed'
10+
| 'failed'
11+
| 'skipped'
12+
| 'pending'
13+
| 'todo'
14+
| 'disabled'
15+
| 'focused';
916

1017
type Callsite = {
1118
column: number;

0 commit comments

Comments
 (0)