A collection of JavaScript reporter classes for the Jasmine BDD testing framework that output test results in various formats including JUnit XML, NUnit XML, TAP, TeamCity, AppVeyor, and Terminal
npx @tessl/cli install tessl/npm-jasmine-reporters@2.5.00
# Jasmine Reporters
1
2
Jasmine Reporters is a collection of JavaScript reporter classes for the Jasmine BDD testing framework. It enables test results to be output in various formats including JUnit XML, NUnit XML, TAP (Test Anything Protocol), TeamCity, AppVeyor, and Terminal formats. The library supports both browser-based and Node.js environments with compatibility for PhantomJS testing scenarios.
3
4
## Package Information
5
6
- **Package Name**: jasmine-reporters
7
- **Package Type**: npm
8
- **Language**: JavaScript
9
- **Installation**: `npm install jasmine-reporters`
10
11
## Core Imports
12
13
```javascript
14
// Node.js - Import all reporters
15
const reporters = require('jasmine-reporters');
16
const junitReporter = new reporters.JUnitXmlReporter(options);
17
```
18
19
```javascript
20
// Browser - Access via global object
21
const junitReporter = new jasmineReporters.JUnitXmlReporter(options);
22
```
23
24
## Basic Usage
25
26
```javascript
27
// Node.js usage
28
const reporters = require('jasmine-reporters');
29
const junitReporter = new reporters.JUnitXmlReporter({
30
savePath: __dirname,
31
consolidateAll: false
32
});
33
jasmine.getEnv().addReporter(junitReporter);
34
35
// Browser usage
36
const tapReporter = new jasmineReporters.TapReporter();
37
jasmine.getEnv().addReporter(tapReporter);
38
39
// Multiple reporters can be used together
40
const terminalReporter = new jasmineReporters.TerminalReporter({
41
verbosity: 2,
42
color: true,
43
showStack: true
44
});
45
jasmine.getEnv().addReporter(terminalReporter);
46
```
47
48
## Architecture
49
50
Jasmine Reporters implements the Jasmine reporter interface with event-driven architecture:
51
52
- **Reporter Interface**: Each reporter implements standard Jasmine 2.x reporter methods (`jasmineStarted`, `suiteStarted`, `specStarted`, `specDone`, `suiteDone`, `jasmineDone`)
53
- **File Output**: XML reporters support multiple environments (Node.js, PhantomJS) with automatic fallback
54
- **Universal Module**: Works in both CommonJS (Node.js) and browser environments via UMD pattern
55
- **Event Tracking**: Maintains internal state for suites and specs using unique IDs with extend pattern for merging updates
56
57
## Capabilities
58
59
### XML Report Generation
60
61
File-based reporters that generate structured XML output for CI/CD integration. Includes JUnit and NUnit formats with extensive configuration options.
62
63
```javascript { .api }
64
// JUnit XML Reporter
65
function JUnitXmlReporter(options?: JUnitOptions): Reporter;
66
67
// NUnit XML Reporter
68
function NUnitXmlReporter(options?: NUnitOptions): Reporter;
69
70
interface JUnitOptions {
71
savePath?: string;
72
consolidateAll?: boolean;
73
consolidate?: boolean;
74
useDotNotation?: boolean;
75
useFullTestName?: boolean;
76
filePrefix?: string;
77
package?: string;
78
modifySuiteName?: (fullName: string, suite: Suite) => string;
79
modifyReportFileName?: (suggestedName: string, suite: Suite) => string;
80
stylesheetPath?: string;
81
suppressDisabled?: boolean;
82
systemOut?: (spec: Spec, qualifiedName: string) => string;
83
captureStdout?: boolean;
84
}
85
86
interface NUnitOptions {
87
savePath?: string;
88
filename?: string;
89
reportName?: string;
90
}
91
```
92
93
[XML Reporters](./xml-reporters.md)
94
95
### Console Output Reporters
96
97
Real-time console output reporters for development and CI environments. Includes TAP protocol, TeamCity integration, and terminal formatting.
98
99
```javascript { .api }
100
// TAP Reporter
101
function TapReporter(): Reporter;
102
103
// TeamCity Reporter
104
function TeamCityReporter(options?: TeamCityOptions): Reporter;
105
106
// Terminal Reporter
107
function TerminalReporter(options?: TerminalOptions): Reporter;
108
109
interface TeamCityOptions {
110
modifySuiteName?: (fullName: string) => string;
111
}
112
113
interface TerminalOptions {
114
verbosity?: number;
115
color?: boolean;
116
showStack?: boolean;
117
}
118
```
119
120
[Console Reporters](./console-reporters.md)
121
122
### CI Integration Reporter
123
124
Cloud-based CI system integration that posts test results to external APIs during test execution.
125
126
```javascript { .api }
127
// AppVeyor Reporter
128
function AppVeyorReporter(options?: AppVeyorOptions): Reporter;
129
130
interface AppVeyorOptions {
131
batchSize?: number;
132
verbosity?: number;
133
color?: boolean;
134
}
135
```
136
137
[CI Integration](./ci-integration.md)
138
139
## Common Types
140
141
```javascript { .api }
142
interface Reporter {
143
jasmineStarted?(summary?: Summary): void;
144
suiteStarted?(suite: Suite): void;
145
specStarted?(spec: Spec): void;
146
specDone?(spec: Spec): void;
147
suiteDone?(suite: Suite): void;
148
jasmineDone?(): void;
149
}
150
151
interface Suite {
152
id: string;
153
description: string;
154
fullName: string;
155
failedExpectations?: FailedExpectation[];
156
}
157
158
interface Spec {
159
id: string;
160
description: string;
161
fullName: string;
162
status: "passed" | "failed" | "pending" | "disabled";
163
failedExpectations: FailedExpectation[];
164
pendingReason?: string;
165
}
166
167
interface FailedExpectation {
168
matcherName?: string;
169
message: string;
170
stack?: string;
171
}
172
173
interface Summary {
174
totalSpecsDefined: number;
175
}
176
```