-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreporter.js
37 lines (32 loc) · 1.12 KB
/
reporter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { styleText } from 'node:util';
const green = msg => styleText('green', msg);
const yellow = msg => styleText('yellow', msg);
const blue = msg => styleText('blue', msg);
const gray = msg => styleText('gray', msg);
const red = msg => styleText('red', msg);
class Reporter {
#formatter
constructor(formatter) {
this.#formatter = formatter
}
updateOutput(results) {
// Clear the console
process.stdout.write('\x1Bc');
// Print all results in tree order
results.forEach((testResults, tree) => {
if (!tree) {
0;
}
process.stdout.write(this.#formatter.formatTree(tree, testResults));
});
}
printSummary(tests, elapsedMs) {
const summary = this.#formatter.generateSummary(tests, elapsedMs);
console.log(summary);
console.log(gray('.'.repeat(33)), '\n');
console.log(`${yellow('Made')} ${blue('with ')}${red('love by')} ${green(`Erick Wendel`)} ${yellow(':)')}`);
console.log(`${green('@erickwendel_')}`);
console.log(gray('.'.repeat(33)));
}
}
export default Reporter;