0
# Console Reporters
1
2
Real-time console output reporters for development and CI environments. Provides immediate feedback during test execution with support for various output formats including TAP protocol, TeamCity integration, and colorized terminal formatting.
3
4
## Capabilities
5
6
### TAP Reporter
7
8
Outputs Test Anything Protocol (TAP) format to console for standardized test result reporting. TAP is widely supported by testing tools and CI systems.
9
10
```javascript { .api }
11
/**
12
* Creates a TAP reporter instance that outputs to console
13
* @returns Reporter instance implementing Jasmine reporter interface
14
*/
15
function TapReporter(): Reporter;
16
```
17
18
**Usage Examples:**
19
20
```javascript
21
// Basic TAP output to console
22
const tapReporter = new jasmineReporters.TapReporter();
23
jasmine.getEnv().addReporter(tapReporter);
24
```
25
26
**TAP Output Format:**
27
28
```
29
TAP version 13
30
ok 1 - Suite Name : should pass
31
not ok 2 - Suite Name : should fail
32
# Failure: Expected true to be false
33
# === STACK TRACE ===
34
# Error: Expected true to be false
35
# at Object.<anonymous> (spec.js:10:5)
36
# === END STACK TRACE ===
37
ok 3 - Another Suite : should skip # SKIP disabled by xit or similar
38
1..3
39
# 3 specs, 1 failure, 1 skipped, 0 disabled in 0.123s.
40
# NOTE: disabled specs are usually a result of xdescribe.
41
```
42
43
### TeamCity Reporter
44
45
Outputs TeamCity service messages for integration with TeamCity CI/CD platform. Provides real-time test progress and results reporting.
46
47
```javascript { .api }
48
/**
49
* Creates a TeamCity reporter instance
50
* @param options - Configuration options for TeamCity integration
51
* @returns Reporter instance implementing Jasmine reporter interface
52
*/
53
function TeamCityReporter(options?: TeamCityOptions): Reporter;
54
55
interface TeamCityOptions {
56
/** Delegate for modifying suite names when used inside TeamCity messages */
57
modifySuiteName?: (fullName: string) => string;
58
}
59
```
60
61
**Usage Examples:**
62
63
```javascript
64
// Basic TeamCity integration
65
const teamcityReporter = new jasmineReporters.TeamCityReporter();
66
jasmine.getEnv().addReporter(teamcityReporter);
67
68
// Custom suite name modification
69
const teamcityReporter = new jasmineReporters.TeamCityReporter({
70
modifySuiteName: function(generatedSuiteName) {
71
return 'MyProject.' + generatedSuiteName;
72
}
73
});
74
```
75
76
**TeamCity Output Format:**
77
78
```
79
##teamcity[progressStart 'Running Jasmine Tests']
80
##teamcity[testSuiteStarted name='Suite Name' timestamp='2023-01-01T12:00:00.000']
81
##teamcity[testStarted name='should pass' captureStandardOutput='true' timestamp='2023-01-01T12:00:00.001']
82
##teamcity[testFinished name='should pass' timestamp='2023-01-01T12:00:00.002']
83
##teamcity[testStarted name='should fail' captureStandardOutput='true' timestamp='2023-01-01T12:00:00.003']
84
##teamcity[testFailed name='should fail' message='Expected true to be false' details='Error stack trace...' timestamp='2023-01-01T12:00:00.125']
85
##teamcity[testFinished name='should fail' timestamp='2023-01-01T12:00:00.125']
86
##teamcity[testSuiteFinished name='Suite Name' timestamp='2023-01-01T12:00:00.125']
87
##teamcity[progressFinish 'Running Jasmine Tests']
88
```
89
90
### Terminal Reporter
91
92
Outputs colorized terminal output with configurable verbosity levels for development and build pipeline integration.
93
94
```javascript { .api }
95
/**
96
* Creates a terminal reporter instance with configurable output formatting
97
* @param options - Configuration options for terminal output
98
* @returns Reporter instance implementing Jasmine reporter interface
99
*/
100
function TerminalReporter(options?: TerminalOptions): Reporter;
101
102
interface TerminalOptions {
103
/** Verbosity level 0-3+, higher values show more detail (default: 2) */
104
verbosity?: number;
105
/** Enable colored output using ANSI escape codes (default: false) */
106
color?: boolean;
107
/** Show stack traces for failed specs (default: false) */
108
showStack?: boolean;
109
}
110
```
111
112
**Verbosity Levels:**
113
114
- **0**: Silent (only final summary)
115
- **1**: Failures only (failed spec names and errors)
116
- **2**: Progress indicators (dots for passed, F for failed, S for skipped)
117
- **3+**: Detailed (suite names, individual spec results, timing)
118
119
**Usage Examples:**
120
121
```javascript
122
// Basic terminal output with default settings
123
const terminalReporter = new jasmineReporters.TerminalReporter();
124
jasmine.getEnv().addReporter(terminalReporter);
125
126
// Colored output with high verbosity
127
const terminalReporter = new jasmineReporters.TerminalReporter({
128
verbosity: 3,
129
color: true,
130
showStack: true
131
});
132
133
// Minimal output for CI environments
134
const terminalReporter = new jasmineReporters.TerminalReporter({
135
verbosity: 1,
136
color: false,
137
showStack: false
138
});
139
```
140
141
**Terminal Output Examples:**
142
143
```
144
// Verbosity 2 (default)
145
..F.S
146
147
Some Suite should fail
148
Expected true to be false
149
150
SUCCESS: 5 specs, 1 failure, 1 skipped, 0 disabled in 0.123s.
151
152
// Verbosity 3 with color
153
Suite Name
154
should pass ... Passed
155
should fail ... Failed
156
Expected true to be false
157
Error: Expected true to be false
158
at Object.<anonymous> (spec.js:10:5)
159
1 of 2 passed (0 skipped, 0 disabled).
160
161
Another Suite
162
should skip ... Skipped
163
1 of 1 passed (1 skipped, 0 disabled).
164
165
SUCCESS: 3 specs, 1 failure, 1 skipped, 0 disabled in 0.123s.
166
```
167
168
### Color Support
169
170
Terminal reporter supports ANSI color codes for enhanced readability.
171
172
**Color Mapping:**
173
- **Green**: Passed specs and success messages
174
- **Red**: Failed specs and error messages
175
- **Yellow**: Disabled specs
176
- **Cyan**: Skipped specs
177
- **Magenta**: Stack trace lines
178
- **Bold**: Suite names and summary text
179
180
### Reporter Lifecycle Methods
181
182
All console reporters implement the complete Jasmine reporter interface.
183
184
```javascript { .api }
185
/** Called when Jasmine starts running */
186
jasmineStarted(summary?: Summary): void;
187
188
/** Called when a test suite starts */
189
suiteStarted(suite: Suite): void;
190
191
/** Called when a test spec starts */
192
specStarted(spec: Spec): void;
193
194
/** Called when a test spec completes */
195
specDone(spec: Spec): void;
196
197
/** Called when a test suite completes */
198
suiteDone(suite: Suite): void;
199
200
/** Called when all tests have completed */
201
jasmineDone(): void;
202
```
203
204
## Performance Considerations
205
206
### Output Buffering
207
208
- **TAP Reporter**: Outputs each spec result immediately
209
- **TeamCity Reporter**: Sends service messages in real-time
210
- **Terminal Reporter**: Buffers output based on verbosity level for better performance
211
212
### Memory Usage
213
214
Console reporters maintain minimal state compared to XML reporters:
215
- No file I/O operations
216
- Limited internal caching of suite/spec data
217
- Immediate output disposal after processing