modestbench 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +6 -2
- package/dist/cli/commands/run.cjs +100 -54
- package/dist/cli/commands/run.cjs.map +1 -1
- package/dist/cli/commands/run.d.cts.map +1 -1
- package/dist/cli/commands/run.d.ts.map +1 -1
- package/dist/cli/commands/run.js +93 -47
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/commands/test.cjs +14 -15
- package/dist/cli/commands/test.cjs.map +1 -1
- package/dist/cli/commands/test.d.cts.map +1 -1
- package/dist/cli/commands/test.d.ts.map +1 -1
- package/dist/cli/commands/test.js +2 -3
- package/dist/cli/commands/test.js.map +1 -1
- package/dist/cli/index.cjs +3 -0
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +4 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/constants.cjs +3 -0
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +3 -0
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.ts +3 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +3 -0
- package/dist/constants.js.map +1 -1
- package/dist/errors/index.cjs +3 -1
- package/dist/errors/index.cjs.map +1 -1
- package/dist/errors/index.d.cts +1 -1
- package/dist/errors/index.d.cts.map +1 -1
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/errors/index.js.map +1 -1
- package/dist/errors/reporter.cjs +45 -1
- package/dist/errors/reporter.cjs.map +1 -1
- package/dist/errors/reporter.d.cts +32 -0
- package/dist/errors/reporter.d.cts.map +1 -1
- package/dist/errors/reporter.d.ts +32 -0
- package/dist/errors/reporter.d.ts.map +1 -1
- package/dist/errors/reporter.js +42 -0
- package/dist/errors/reporter.js.map +1 -1
- package/dist/index.cjs +19 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/reporters/index.cjs +3 -1
- package/dist/reporters/index.cjs.map +1 -1
- package/dist/reporters/index.d.cts +1 -0
- package/dist/reporters/index.d.cts.map +1 -1
- package/dist/reporters/index.d.ts +1 -0
- package/dist/reporters/index.d.ts.map +1 -1
- package/dist/reporters/index.js +1 -0
- package/dist/reporters/index.js.map +1 -1
- package/dist/reporters/nyan.cjs +318 -0
- package/dist/reporters/nyan.cjs.map +1 -0
- package/dist/reporters/nyan.d.cts +118 -0
- package/dist/reporters/nyan.d.cts.map +1 -0
- package/dist/reporters/nyan.d.ts +118 -0
- package/dist/reporters/nyan.d.ts.map +1 -0
- package/dist/reporters/nyan.js +314 -0
- package/dist/reporters/nyan.js.map +1 -0
- package/dist/services/reporter-loader.cjs +281 -0
- package/dist/services/reporter-loader.cjs.map +1 -0
- package/dist/services/reporter-loader.d.cts +67 -0
- package/dist/services/reporter-loader.d.cts.map +1 -0
- package/dist/services/reporter-loader.d.ts +67 -0
- package/dist/services/reporter-loader.d.ts.map +1 -0
- package/dist/services/reporter-loader.js +241 -0
- package/dist/services/reporter-loader.js.map +1 -0
- package/dist/types/core.cjs.map +1 -1
- package/dist/types/core.d.cts +13 -12
- package/dist/types/core.d.cts.map +1 -1
- package/dist/types/core.d.ts +13 -12
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/core.js.map +1 -1
- package/dist/types/index.cjs +0 -2
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +0 -2
- package/dist/types/index.js.map +1 -1
- package/dist/types/plugin.cjs +9 -0
- package/dist/types/plugin.cjs.map +1 -0
- package/dist/types/plugin.d.cts +179 -0
- package/dist/types/plugin.d.cts.map +1 -0
- package/dist/types/plugin.d.ts +179 -0
- package/dist/types/plugin.d.ts.map +1 -0
- package/dist/types/plugin.js +8 -0
- package/dist/types/plugin.js.map +1 -0
- package/dist/utils/package.cjs +66 -5
- package/dist/utils/package.cjs.map +1 -1
- package/dist/utils/package.d.cts +6 -0
- package/dist/utils/package.d.cts.map +1 -1
- package/dist/utils/package.d.ts +6 -0
- package/dist/utils/package.d.ts.map +1 -1
- package/dist/utils/package.js +31 -1
- package/dist/utils/package.js.map +1 -1
- package/dist/utils/reporter-utils.cjs +90 -0
- package/dist/utils/reporter-utils.cjs.map +1 -0
- package/dist/utils/reporter-utils.d.cts +42 -0
- package/dist/utils/reporter-utils.d.cts.map +1 -0
- package/dist/utils/reporter-utils.d.ts +42 -0
- package/dist/utils/reporter-utils.d.ts.map +1 -0
- package/dist/utils/reporter-utils.js +83 -0
- package/dist/utils/reporter-utils.js.map +1 -0
- package/package.json +6 -6
- package/src/cli/commands/run.ts +130 -64
- package/src/cli/commands/test.ts +2 -3
- package/src/cli/index.ts +8 -0
- package/src/constants.ts +4 -1
- package/src/errors/index.ts +2 -0
- package/src/errors/reporter.ts +55 -0
- package/src/index.ts +22 -1
- package/src/reporters/index.ts +1 -0
- package/src/reporters/nyan.ts +409 -0
- package/src/services/reporter-loader.ts +323 -0
- package/src/types/core.ts +16 -14
- package/src/types/index.ts +3 -3
- package/src/types/plugin.ts +197 -0
- package/src/utils/package.ts +32 -1
- package/src/utils/reporter-utils.ts +85 -0
- package/dist/types/cli.cjs +0 -12
- package/dist/types/cli.cjs.map +0 -1
- package/dist/types/cli.d.cts +0 -75
- package/dist/types/cli.d.cts.map +0 -1
- package/dist/types/cli.d.ts +0 -75
- package/dist/types/cli.d.ts.map +0 -1
- package/dist/types/cli.js +0 -9
- package/dist/types/cli.js.map +0 -1
- package/src/types/cli.ts +0 -82
package/src/reporters/index.ts
CHANGED
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ModestBench Nyan Cat Reporter
|
|
3
|
+
*
|
|
4
|
+
* Because benchmarking should be more colorful. Displays an animated nyan cat
|
|
5
|
+
* flying through a rainbow trail as benchmarks complete.
|
|
6
|
+
*
|
|
7
|
+
* Based on Mocha's legendary nyan reporter, adapted for the glory of
|
|
8
|
+
* performance measurement.
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type {
|
|
14
|
+
BenchmarkRun,
|
|
15
|
+
FileResult,
|
|
16
|
+
SuiteResult,
|
|
17
|
+
TaskResult,
|
|
18
|
+
} from '../types/index.js';
|
|
19
|
+
|
|
20
|
+
import { BaseReporter } from '../services/reporter-registry.js';
|
|
21
|
+
import { colors } from '../utils/ansi.js';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Nyan Cat reporter - because your benchmarks deserve rainbow power
|
|
25
|
+
*/
|
|
26
|
+
export class NyanReporter extends BaseReporter {
|
|
27
|
+
/** Index into rainbow colors for cycling */
|
|
28
|
+
private colorIndex = 0;
|
|
29
|
+
|
|
30
|
+
/** Current file being processed */
|
|
31
|
+
private currentFile = '';
|
|
32
|
+
|
|
33
|
+
/** Current suite being processed */
|
|
34
|
+
private currentSuite = '';
|
|
35
|
+
|
|
36
|
+
/** Total failed tasks */
|
|
37
|
+
private failed = 0;
|
|
38
|
+
|
|
39
|
+
/** Collected failures for summary */
|
|
40
|
+
private failures: Array<{
|
|
41
|
+
error: string;
|
|
42
|
+
file: string;
|
|
43
|
+
suite: string;
|
|
44
|
+
task: string;
|
|
45
|
+
}> = [];
|
|
46
|
+
|
|
47
|
+
/** Number of lines the cat occupies */
|
|
48
|
+
private readonly numberOfLines = 4;
|
|
49
|
+
|
|
50
|
+
/** Total passed tasks */
|
|
51
|
+
private passed = 0;
|
|
52
|
+
|
|
53
|
+
/** Whether the display is active */
|
|
54
|
+
private progressActive = false;
|
|
55
|
+
|
|
56
|
+
/** Quiet mode - suppress output */
|
|
57
|
+
private readonly quiet: boolean;
|
|
58
|
+
|
|
59
|
+
/** Generated rainbow color palette */
|
|
60
|
+
private rainbowColors: number[] = [];
|
|
61
|
+
|
|
62
|
+
/** Width of scoreboard */
|
|
63
|
+
private readonly scoreboardWidth = 5;
|
|
64
|
+
|
|
65
|
+
/** Start time for duration calculation */
|
|
66
|
+
private startTime = 0;
|
|
67
|
+
|
|
68
|
+
/** Animation tick (alternates between frames) */
|
|
69
|
+
private tick = false;
|
|
70
|
+
|
|
71
|
+
/** Rainbow trail storage - one trajectory per cat line */
|
|
72
|
+
private trajectories: string[][] = [[], [], [], []];
|
|
73
|
+
|
|
74
|
+
/** Maximum width of the rainbow trail */
|
|
75
|
+
private trajectoryWidthMax = 0;
|
|
76
|
+
|
|
77
|
+
/** Whether to use colors */
|
|
78
|
+
private readonly useColor: boolean;
|
|
79
|
+
|
|
80
|
+
constructor(
|
|
81
|
+
options: {
|
|
82
|
+
color?: boolean;
|
|
83
|
+
quiet?: boolean;
|
|
84
|
+
} = {},
|
|
85
|
+
) {
|
|
86
|
+
super('nyan', options);
|
|
87
|
+
|
|
88
|
+
this.quiet = options.quiet ?? false;
|
|
89
|
+
|
|
90
|
+
// Auto-detect color support if not explicitly set
|
|
91
|
+
this.useColor =
|
|
92
|
+
options.color ??
|
|
93
|
+
(process.stdout.isTTY &&
|
|
94
|
+
process.env.FORCE_COLOR !== '0' &&
|
|
95
|
+
process.env.NO_COLOR == null);
|
|
96
|
+
|
|
97
|
+
// Generate the rainbow colors on construction
|
|
98
|
+
this.rainbowColors = this.generateColors();
|
|
99
|
+
|
|
100
|
+
// Calculate trajectory width based on terminal width
|
|
101
|
+
// Leave room for scoreboard (5) + cat (11) + some padding
|
|
102
|
+
const termWidth = process.stdout.columns || 80;
|
|
103
|
+
const nyanCatWidth = 11;
|
|
104
|
+
this.trajectoryWidthMax = Math.floor(termWidth * 0.75) - nyanCatWidth;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
onEnd(run: BenchmarkRun): void {
|
|
108
|
+
if (this.quiet) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Show cursor and move past the cat
|
|
113
|
+
this.showCursor();
|
|
114
|
+
for (let i = 0; i < this.numberOfLines; i++) {
|
|
115
|
+
process.stdout.write('\n');
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Print summary
|
|
119
|
+
this.printEpilogue(run);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
onError(error: Error): void {
|
|
123
|
+
if (this.quiet) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Make sure cursor is visible
|
|
128
|
+
this.showCursor();
|
|
129
|
+
|
|
130
|
+
console.error(`\n${colors.red}Error: ${error.message}${colors.reset}`);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
onFileEnd(_result: FileResult): void {
|
|
134
|
+
// Just keep flying
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
onFileStart(file: string): void {
|
|
138
|
+
this.currentFile = file;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
onStart(_run: BenchmarkRun): void {
|
|
142
|
+
this.startTime = Date.now();
|
|
143
|
+
this.passed = 0;
|
|
144
|
+
this.failed = 0;
|
|
145
|
+
this.failures = [];
|
|
146
|
+
this.colorIndex = 0;
|
|
147
|
+
this.tick = false;
|
|
148
|
+
this.trajectories = [[], [], [], []];
|
|
149
|
+
|
|
150
|
+
if (this.quiet) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Hide cursor for cleaner animation
|
|
155
|
+
this.hideCursor();
|
|
156
|
+
|
|
157
|
+
// Initial draw
|
|
158
|
+
this.draw();
|
|
159
|
+
this.progressActive = true;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
onSuiteEnd(_result: SuiteResult): void {
|
|
163
|
+
// Keep flying
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
onSuiteStart(suite: string): void {
|
|
167
|
+
this.currentSuite = suite;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
onTaskResult(result: TaskResult): void {
|
|
171
|
+
if (result.error) {
|
|
172
|
+
this.failed++;
|
|
173
|
+
this.failures.push({
|
|
174
|
+
error: result.error.message || String(result.error),
|
|
175
|
+
file: this.currentFile,
|
|
176
|
+
suite: this.currentSuite,
|
|
177
|
+
task: result.name,
|
|
178
|
+
});
|
|
179
|
+
} else if (!result.aborted) {
|
|
180
|
+
this.passed++;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (this.quiet) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
this.draw();
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
onTaskStart(_task: string): void {
|
|
191
|
+
// The cat flies on results, not starts
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Append a segment to the rainbow trail
|
|
196
|
+
*/
|
|
197
|
+
private appendRainbow(): void {
|
|
198
|
+
const segment = this.tick ? '_' : '-';
|
|
199
|
+
const rainbowified = this.rainbowify(segment);
|
|
200
|
+
|
|
201
|
+
for (let index = 0; index < this.numberOfLines; index++) {
|
|
202
|
+
const trajectory = this.trajectories[index]!;
|
|
203
|
+
if (trajectory.length >= this.trajectoryWidthMax) {
|
|
204
|
+
trajectory.shift();
|
|
205
|
+
}
|
|
206
|
+
trajectory.push(rainbowified);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Move cursor down n lines
|
|
212
|
+
*/
|
|
213
|
+
private cursorDown(n: number): void {
|
|
214
|
+
process.stdout.write(`\x1b[${n}B`);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Move cursor up n lines
|
|
219
|
+
*/
|
|
220
|
+
private cursorUp(n: number): void {
|
|
221
|
+
process.stdout.write(`\x1b[${n}A`);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Draw the complete nyan cat scene
|
|
226
|
+
*/
|
|
227
|
+
private draw(): void {
|
|
228
|
+
this.appendRainbow();
|
|
229
|
+
this.drawScoreboard();
|
|
230
|
+
this.drawRainbow();
|
|
231
|
+
this.drawNyanCat();
|
|
232
|
+
this.tick = !this.tick;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Draw the nyan cat ASCII art
|
|
237
|
+
*/
|
|
238
|
+
private drawNyanCat(): void {
|
|
239
|
+
const startWidth = this.scoreboardWidth + this.trajectories[0]!.length;
|
|
240
|
+
const dist = `\x1b[${startWidth}C`;
|
|
241
|
+
|
|
242
|
+
process.stdout.write(dist);
|
|
243
|
+
process.stdout.write('_,------,');
|
|
244
|
+
process.stdout.write('\n');
|
|
245
|
+
|
|
246
|
+
process.stdout.write(dist);
|
|
247
|
+
const padding1 = this.tick ? ' ' : ' ';
|
|
248
|
+
process.stdout.write(`_|${padding1}/\\_/\\ `);
|
|
249
|
+
process.stdout.write('\n');
|
|
250
|
+
|
|
251
|
+
process.stdout.write(dist);
|
|
252
|
+
const padding2 = this.tick ? '_' : '__';
|
|
253
|
+
const tail = this.tick ? '~' : '^';
|
|
254
|
+
process.stdout.write(`${tail}|${padding2}${this.face()} `);
|
|
255
|
+
process.stdout.write('\n');
|
|
256
|
+
|
|
257
|
+
process.stdout.write(dist);
|
|
258
|
+
const padding3 = this.tick ? ' ' : ' ';
|
|
259
|
+
process.stdout.write(`${padding3}"" "" `);
|
|
260
|
+
process.stdout.write('\n');
|
|
261
|
+
|
|
262
|
+
this.cursorUp(this.numberOfLines);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Draw the rainbow trail
|
|
267
|
+
*/
|
|
268
|
+
private drawRainbow(): void {
|
|
269
|
+
for (const line of this.trajectories) {
|
|
270
|
+
process.stdout.write(`\x1b[${this.scoreboardWidth}C`);
|
|
271
|
+
process.stdout.write(line.join(''));
|
|
272
|
+
process.stdout.write('\n');
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
this.cursorUp(this.numberOfLines);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Draw the scoreboard showing pass/fail counts
|
|
280
|
+
*/
|
|
281
|
+
private drawScoreboard(): void {
|
|
282
|
+
const draw = (type: 'green' | 'red', n: number) => {
|
|
283
|
+
process.stdout.write(' ');
|
|
284
|
+
if (this.useColor) {
|
|
285
|
+
process.stdout.write(`${colors[type]}${n}${colors.reset}`);
|
|
286
|
+
} else {
|
|
287
|
+
process.stdout.write(String(n));
|
|
288
|
+
}
|
|
289
|
+
process.stdout.write('\n');
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
draw('green', this.passed);
|
|
293
|
+
draw('red', this.failed);
|
|
294
|
+
process.stdout.write('\n');
|
|
295
|
+
process.stdout.write('\n');
|
|
296
|
+
|
|
297
|
+
this.cursorUp(this.numberOfLines);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Get the nyan cat's face based on current state
|
|
302
|
+
*/
|
|
303
|
+
private face(): string {
|
|
304
|
+
if (this.failed > 0) {
|
|
305
|
+
return '( x .x)';
|
|
306
|
+
} else if (this.passed > 0) {
|
|
307
|
+
return '( ^ .^)';
|
|
308
|
+
}
|
|
309
|
+
return '( - .-)';
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Generate rainbow colors using sine wave color cycling
|
|
314
|
+
*
|
|
315
|
+
* Uses 256-color palette (colors 16-231 are a 6x6x6 color cube)
|
|
316
|
+
*/
|
|
317
|
+
private generateColors(): number[] {
|
|
318
|
+
const colorList: number[] = [];
|
|
319
|
+
|
|
320
|
+
// Generate 42 colors (6 * 7) cycling through the spectrum
|
|
321
|
+
for (let i = 0; i < 6 * 7; i++) {
|
|
322
|
+
const pi3 = Math.floor(Math.PI / 3);
|
|
323
|
+
const n = i * (1.0 / 6);
|
|
324
|
+
const r = Math.floor(3 * Math.sin(n) + 3);
|
|
325
|
+
const g = Math.floor(3 * Math.sin(n + 2 * pi3) + 3);
|
|
326
|
+
const b = Math.floor(3 * Math.sin(n + 4 * pi3) + 3);
|
|
327
|
+
// Calculate 256-color code from RGB values (16 + 36*r + 6*g + b)
|
|
328
|
+
colorList.push(36 * r + 6 * g + b + 16);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
return colorList;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Hide the cursor
|
|
336
|
+
*/
|
|
337
|
+
private hideCursor(): void {
|
|
338
|
+
if (process.stdout.isTTY) {
|
|
339
|
+
process.stdout.write('\x1b[?25l');
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Print the epilogue summary after the run
|
|
345
|
+
*/
|
|
346
|
+
private printEpilogue(run: BenchmarkRun): void {
|
|
347
|
+
const duration = Date.now() - this.startTime;
|
|
348
|
+
const durationStr = BaseReporter.formatDuration(duration * 1000000);
|
|
349
|
+
|
|
350
|
+
console.log();
|
|
351
|
+
console.log(
|
|
352
|
+
` ${this.useColor ? colors.green : ''}${this.passed} passing${this.useColor ? colors.reset : ''} ${this.useColor ? colors.gray : ''}(${durationStr})${this.useColor ? colors.reset : ''}`,
|
|
353
|
+
);
|
|
354
|
+
|
|
355
|
+
if (this.failed > 0) {
|
|
356
|
+
console.log(
|
|
357
|
+
` ${this.useColor ? colors.red : ''}${this.failed} failing${this.useColor ? colors.reset : ''}`,
|
|
358
|
+
);
|
|
359
|
+
console.log();
|
|
360
|
+
|
|
361
|
+
// Print failure details
|
|
362
|
+
for (let i = 0; i < this.failures.length; i++) {
|
|
363
|
+
const failure = this.failures[i]!;
|
|
364
|
+
console.log(
|
|
365
|
+
` ${i + 1}) ${failure.suite === 'default' ? '' : failure.suite + ' > '}${failure.task}`,
|
|
366
|
+
);
|
|
367
|
+
console.log(
|
|
368
|
+
` ${this.useColor ? colors.red : ''}${failure.error}${this.useColor ? colors.reset : ''}`,
|
|
369
|
+
);
|
|
370
|
+
console.log();
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// Show total files/suites for context
|
|
375
|
+
let totalSuites = 0;
|
|
376
|
+
for (const file of run.files) {
|
|
377
|
+
totalSuites += file.suites.length;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
console.log();
|
|
381
|
+
console.log(
|
|
382
|
+
` ${this.useColor ? colors.gray : ''}Files: ${run.files.length} | Suites: ${totalSuites} | Tasks: ${this.passed + this.failed}${this.useColor ? colors.reset : ''}`,
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Apply rainbow coloring to a string
|
|
388
|
+
*/
|
|
389
|
+
private rainbowify(str: string): string {
|
|
390
|
+
if (!this.useColor) {
|
|
391
|
+
return str;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
const color =
|
|
395
|
+
this.rainbowColors[this.colorIndex % this.rainbowColors.length]!;
|
|
396
|
+
this.colorIndex += 1;
|
|
397
|
+
|
|
398
|
+
return `\x1b[38;5;${color}m${str}\x1b[0m`;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Show the cursor
|
|
403
|
+
*/
|
|
404
|
+
private showCursor(): void {
|
|
405
|
+
if (process.stdout.isTTY) {
|
|
406
|
+
process.stdout.write('\x1b[?25h');
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|