forked from codeceptjs/CodeceptJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
output.js
110 lines (91 loc) · 2.41 KB
/
output.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
'use strict';
let colors = require('colors');
let print = console.log;
let symbols = require('mocha/lib/reporters/base').symbols;
let styles = {
error: colors.bgRed.white.bold,
success: colors.bgGreen.white.bold,
scenario: colors.magenta.bold,
basic: colors.white,
debug: colors.cyan
};
let outputLevel = 0;
module.exports = {
colors,
styles,
print,
stepShift: 0,
level: (level) => {
if (level) outputLevel = level;
return outputLevel;
},
debug: (msg) => {
if (outputLevel === 2) print(' '.repeat(this.stepShift), styles.debug("> " + msg));
},
error: (msg) => {
print(styles.error(msg));
},
success: (msg) => {
print(styles.success(msg));
},
step: function (step) {
if (outputLevel === 0) return;
let sym = process.platform === 'win32' ? '*' : '•';
print(' '.repeat(this.stepShift), `${sym} ${step.toString()}`);
},
suite: {
started: (suite) => {
if (!suite.title) return;
print(colors.bold(suite.title) + ' --');
}
},
test: {
started: (test) => {
print(` ${colors.magenta.bold(test.title)}`);
},
passed: (test) => {
print(` ${colors.green.bold(symbols.ok)} ${test.title} ${colors.grey('in ' + test.duration + 'ms')}`);
},
failed: (test) => {
print(` ${colors.red.bold(symbols.err)} ${test.title} ${colors.grey('in ' + test.duration + 'ms')}`);
},
skipped: (test) => {
print(` ${colors.yellow.bold('S')} ${test.title}`);
}
},
scenario: {
started: (test) => {
},
passed: (test) => {
print(' ' + colors.green.bold(`${symbols.ok} OK`) + ' ' + colors.grey(`in ${test.duration}ms`));
print();
},
failed: (test) => {
print(' ' + colors.red.bold(`${symbols.err} FAILED`) + ' ' + colors.grey(`in ${test.duration}ms`));
print();
}
},
say: (message) => {
print(` ${colors.cyan.bold(message)}`);
},
result: (passed, failed, pending, duration) => {
let style = colors.bgGreen;
let msg = ` ${passed || 0} passed`;
let status = style.bold(` OK `);
if (failed) {
style = style.bgRed;
status = style.bold(` FAIL `);
msg += `, ${failed} failed`;
}
status += style.grey(` |`);
if (pending) {
if (!failed) style = style.bgYellow;
msg += `, ${pending} pending`;
}
msg += " ";
print(status + style(msg) + colors.grey(` // ${duration}`));
}
};
function ind() {
return " ";
}