-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate.js
62 lines (54 loc) · 1.67 KB
/
generate.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
'use strict';
var chalk = require('chalk');
var results = require('./results');
function generateKarmaReport(options) {
var allResults = options.results;
var counts = options.counts;
var displayBanners = (counts.failure > 0 || counts.skipped);
var stack = [];
if (displayBanners) {
process.stdout.write(bannerStart + '\n');
}
allResults.forEach(function(info, idx) {
//inspect stack and write new line if changed
var suite = info.result.suite;
while (stack.length > suite.length) {
stack.pop();
}
suite.forEach(function(suiteLoc, idx) {
var stackLoc;
if (idx < stack.length) {
stackLoc = stack[idx];
if (suiteLoc === stackLoc) {
return;
}
stack[idx] = suiteLoc;
process.stdout.write(chalk.blue(suiteLoc) + '\n');
}
else {
if (suite.length > stack.length) {
stack.push(suiteLoc);
process.stdout.write(chalk.blue(suiteLoc) + '\n');
}
}
});
//write result line
process.stdout.write(
results.types[info.type].symbol + ' ' +
info.result.description + '\n');
});
process.stdout.write('Karma tests: ' + counts.success + '/' + counts.total +
(counts.skipped === 0 ? '' : ' (' + counts.skipped + ' skipped)') + '\n');
if (displayBanners > 0) {
process.stdout.write(bannerStop + '\n');
}
}
//NOTE we default to a banner width of 80,
//If it becomes a requirement, pass this in via a cofniguration object
var bannerWidth = 80;
var hr = new Array(bannerWidth + 1);
var bannerStart = (hr.join('\u25BC') + '\n');
var bannerStop = (hr.join('\u25B2') + '\n');
module.exports = {
report: generateKarmaReport,
};