-
Notifications
You must be signed in to change notification settings - Fork 2
/
gorilla-reporter.js
80 lines (69 loc) · 1.88 KB
/
gorilla-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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
'use strict';
const mocha = require('mocha');
const chalk = require('chalk');
const green = chalk.greenBright;
const yellow = chalk.yellowBright;
const red = chalk.redBright;
const blue = chalk.blueBright;
const gray = chalk.gray;
const BANANA = yellow(`
.-.
/ |
| /
.'\\|.-; _
/.-.;\\ |\\|
' |'._/ \`
| \\
\\ |
jgs '-'
`);
function write(text) {
process.stdout.write(text);
}
function gorillaSays(text) {
const words = text ? text : '';
write(chalk.hex('#512a07')(`
."\`".
.-./ _=_ \\.-. ${words}
{ (,(oYo),) }} )
{{ | " |} } /
{ { \\(---)/ }}
{{ }'-=-'{ } }
{ { }._:_.{ }}
{{ } -:- { } }
jgs {_{ }\`===\`{ _}
((((\\) (/)))) `))
}
function GorillaReporter(runner) {
mocha.reporters.Base.call(this, runner);
var passes = 0;
var failures = 0;
runner.on('start', () => {
gorillaSays(`哥! 不要緊張~~`);
write('\n');
});
runner.on('pass', (test) => {
passes++;
write(`${green('A_A')}\t${test.fullTitle()}\n`);
});
runner.on('fail', (test, err) => {
failures++;
write('\n');
write(`${red('幹')} ${test.fullTitle()} ${gray(`這個錯了啦: ${err.message}`)}\n`);
});
runner.on('pending', (test) => {
write('\n');
write(`\n${blue('額')} ${gray('哥這個')} ${test.fullTitle()} ${gray('不用測')}\n`);
});
runner.on('end', () => {
write('\n');
if (failures > 0) {
write(`${passes + failures}${gray('個裡面錯了')}${failures}${gray('個, 我要被你笑死!')}`);
} else {
write(BANANA);
write(`${passes}/${passes + failures} ${gray('全部都對了! 很不錯耶~~')}`);
}
write('\n');
});
}
module.exports = GorillaReporter;