-
Notifications
You must be signed in to change notification settings - Fork 2
/
karma.js
78 lines (59 loc) · 1.48 KB
/
karma.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
'use strict';
const log = require('console');
const colors = require('colors/safe');
const _ = require('lodash');
var SuiteReporter = function(baseReporterDecorator) {
baseReporterDecorator(this);
this.levels = [];
this.separator = ' ';
this.showSuite = function(suites){
var levels = _.clone(suites);
var level = levels.length;
var description;
_.forEach(levels, suite => {
if(!this.levels[suite]){
description = suite;
this.levels[suite] = level;
levels.unshift();
}
});
if(description){
log.log(_.repeat(this.separator, level),
colors.gray(description));
}
return level;
};
this.onBrowserError = function(browser, error){
log.error(colors.red(error));
};
this.onSpecComplete = function(browser, result){
var level = this.showSuite(result.suite);
var symbol = '●';
var color = 'red';
if(result.success) {
color = 'green';
symbol = '✔';
} else if(result.skipped === true) {
color = 'yellow';
} else {
symbol = '✘';
}
log.log(this.separator,
_.repeat(this.separator, level),
colors[color](symbol),
result.description);
_.forEach(result.log, error => {
log.log(this.separator,
_.repeat(this.separator, level),
'↳',
colors.red(error));
});
};
};
SuiteReporter.$inject = ['baseReporterDecorator'];
module.exports = {
'reporter:suite': [
'type',
SuiteReporter
]
};