-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathtest.it-firebug.js
119 lines (91 loc) · 3.21 KB
/
test.it-firebug.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
111
112
113
114
115
116
117
118
119
(function(scope) {
function firebugConsole(){
/** colors for console.log %c */
var green = "color: green",
red = "color: red;",
orange = "color: orange",
blue = "color: blue",
grey = "color: grey",
normal = "color: normal; font-weight:normal;";
function _print(entity){
if (entity.type==="group") {
_group(entity);
} else if (entity.type==="test") {
_test(entity);
} else if (entity.error) {
_error(entity);
} else console.log.apply(console, arguments);
};
this.print = _print;
function _error(error){
console.group('%c%s%c: %s',orange,error.type,normal,error.message);
if (error.stack) console.log(error.stack);
console.dir(error.error);
console.groupEnd();
};
this.error = _error;
function _test(test){
var color = (test.status==='pass')?green:
(test.status==='fail')?red:
(test.status==='error')?orange:normal;
var args = ['%c%s%c',color,test.status,normal];
if (typeof test.time !== 'undefined') {
args[0] += ' (%c%s%c ms)';
args.push(blue,test.time,normal);
};
if (test.comment) {
args[0] += ': %s';
args.push(test.comment);
}
if (test.status==='pass') {
console.groupCollapsed.apply(console, args);
} else {
console.group.apply(console, args);
}
if (test.description) console.log(test.description);
if (test.trace) {
console.group('trace');
console.log(test.trace);
console.groupEnd();
}
if (test.error) _error(test.error);
console.log(test.argument);
console.groupEnd();
};
this.test = _test;
function _group(group) {
var color = (group.status==='pass')?green:
(group.status==='fail')?red:
(group.status==='error')?orange:normal;
var args = ['%s - %c%s%c',group.name,color,group.status,normal];
args[0] += ' - %c%d%c/%c%d%c/%c%d%c';
args.push((group.result.pass > 0) ? green : grey,group.result.pass,normal
, (group.result.fail > 0) ? red : grey,group.result.fail,normal
, (group.result.error > 0) ? orange : grey,group.result.error,normal);
args[0] += ' (%c%s%c ms)';
args.push(blue,group.time,normal);
if (group.comment) {
args[0] += ': %s';
args.push(group.comment);
};
if (group.status==='pass') {
console.groupCollapsed.apply(console, args);
} else {
console.group.apply(console, args);
}
if (group.description) console.log(group.description);
if (group.trace) {
console.group('trace');
console.log(group.trace);
console.groupEnd();
}
for (var i in group.stack) {
_print(group.stack[i]);
}
if (group.error) _error(group.error);
console.groupEnd();
};
this.group = _group;
}
scope.firebugConsole = new firebugConsole;
})(this);