-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgrouped-by-browser.js
47 lines (40 loc) · 1.27 KB
/
grouped-by-browser.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
const FailureOnlyReporter = require('./failure-only-reporter');
class FailureOnlyPerBrowserReporter extends FailureOnlyReporter {
constructor(...args) {
super(...args);
this._resultsByBrowser = {};
}
report(prefix, data) {
if (!this._resultsByBrowser[prefix]) {
this._resultsByBrowser[prefix] = {
total: 0,
pass: 0,
skipped: 0,
};
}
this._resultsByBrowser[prefix].total++;
if (data.skipped) {
this._resultsByBrowser[prefix].skipped++;
} else if (data.passed) {
this._resultsByBrowser[prefix].pass++;
}
super.report(prefix, data);
}
summaryDisplay() {
let originalSummary = super.summaryDisplay();
let lines = [];
let resultsByBrowser = this._resultsByBrowser;
Object.keys(resultsByBrowser).forEach(function(browser) {
let results = resultsByBrowser[browser];
lines.push('#');
lines.push('# Browser: ' + browser);
lines.push('# tests ' + results.total);
lines.push('# pass ' + results.pass);
lines.push('# skip ' + results.skipped);
lines.push('# fail ' + (results.total - results.pass - results.skipped));
});
lines.push('#');
return lines.join('\n') + '\n' + originalSummary;
}
}
module.exports = FailureOnlyPerBrowserReporter;