or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

circus.mdconfig.mdglobal.mdindex.mdtest-result.mdtransform.md
tile.json

test-result.mddocs/

0

# Test Result Types

1

2

Types for test execution results, assertions, and error handling to support test reporting and analysis. These types avoid large dependency trees while providing complete test result structures.

3

4

## Capabilities

5

6

### Test Status Types

7

8

Core status values for test execution outcomes.

9

10

```typescript { .api }

11

/**

12

* Test execution status values

13

*/

14

type Status =

15

| 'passed' // Test completed successfully

16

| 'failed' // Test failed with errors

17

| 'skipped' // Test was skipped (test.skip)

18

| 'pending' // Test is pending execution

19

| 'todo' // Test is marked as todo (test.todo)

20

| 'disabled' // Test is disabled

21

| 'focused'; // Test is focused (test.only)

22

```

23

24

### Location Information

25

26

Types for representing test location information.

27

28

```typescript { .api }

29

/**

30

* Source code location (line and column)

31

*/

32

type Callsite = {

33

column: number;

34

line: number;

35

};

36

```

37

38

### Assertion Result Interface

39

40

Complete interface for individual test assertion results.

41

42

```typescript { .api }

43

/**

44

* Result of an individual test assertion

45

* Designed to avoid huge dependency trees for result processing

46

*/

47

interface AssertionResult {

48

/** Array of ancestor describe block titles */

49

ancestorTitles: Array<string>;

50

51

/** Test execution duration in milliseconds */

52

duration?: number | null;

53

54

/** Test start timestamp */

55

startAt?: number | null;

56

57

/**

58

* Whether test.failing() was used

59

* @see https://jestjs.io/docs/api#testfailingname-fn-timeout

60

*/

61

failing?: boolean;

62

63

/**

64

* Raw failure details (may lose function/symbol types)

65

* Function or symbol types may be lost because they cannot be

66

* serialized correctly between workers, but information about

67

* them will be available in failureMessages

68

*/

69

failureDetails: Array<unknown>;

70

71

/** Array of failure message strings */

72

failureMessages: Array<string>;

73

74

/** Full test name including ancestor titles */

75

fullName: string;

76

77

/** Number of times test was invoked (for retries) */

78

invocations?: number;

79

80

/** Source location of the test */

81

location?: Callsite | null;

82

83

/** Number of assertions that passed */

84

numPassingAsserts: number;

85

86

/** Reasons for test retries */

87

retryReasons?: Array<string>;

88

89

/** Test execution status */

90

status: Status;

91

92

/** Test title (without ancestor context) */

93

title: string;

94

}

95

```

96

97

### Serializable Error Interface

98

99

Interface for errors that can be serialized between Jest workers.

100

101

```typescript { .api }

102

/**

103

* Error that can be serialized between workers

104

* Used to avoid dependency trees while maintaining error information

105

*/

106

interface SerializableError {

107

/** Error code (if available) */

108

code?: unknown;

109

110

/** Error message */

111

message: string;

112

113

/** Error stack trace */

114

stack: string | null | undefined;

115

116

/** Error type/name */

117

type?: string;

118

}

119

```

120

121

**Usage Examples:**

122

123

```typescript

124

import type { TestResult } from "@jest/types";

125

126

// Process test assertion results

127

const processAssertionResult = (result: TestResult.AssertionResult) => {

128

const fullPath = [...result.ancestorTitles, result.title].join(' > ');

129

130

if (result.status === 'passed') {

131

console.log(`✓ ${fullPath} (${result.duration}ms)`);

132

} else if (result.status === 'failed') {

133

console.log(`✗ ${fullPath}`);

134

result.failureMessages.forEach(message => {

135

console.log(` ${message}`);

136

});

137

}

138

};

139

140

// Create a serializable error

141

const createSerializableError = (error: Error): TestResult.SerializableError => {

142

return {

143

message: error.message,

144

stack: error.stack,

145

type: error.name,

146

code: (error as any).code,

147

};

148

};

149

150

// Check test status

151

const isTestPassing = (result: TestResult.AssertionResult): boolean => {

152

return result.status === 'passed';

153

};

154

155

// Get test summary

156

const getTestSummary = (results: TestResult.AssertionResult[]) => {

157

const passed = results.filter(r => r.status === 'passed').length;

158

const failed = results.filter(r => r.status === 'failed').length;

159

const skipped = results.filter(r => r.status === 'skipped').length;

160

const todo = results.filter(r => r.status === 'todo').length;

161

162

return { passed, failed, skipped, todo, total: results.length };

163

};

164

```