forked from dequelabs/axe-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathno-ui-reporter.js
More file actions
34 lines (30 loc) · 927 Bytes
/
Copy pathno-ui-reporter.js
File metadata and controls
34 lines (30 loc) · 927 Bytes
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
/*global mocha, console */
(() => {
if (!mocha || !mocha.reporter || !mocha.reporter('base')) {
return;
}
const Base = mocha.reporter('base')._reporter;
mocha.reporter(function (runner) {
Base.call(this, runner);
let passes = 0;
let failures = 0;
runner.on('pass', test => {
passes++;
console.log('pass: %s', test.fullTitle());
});
runner.on('fail', (test, err) => {
failures++;
console.error('fail: %s -- error: %s', test.fullTitle(), err.message);
});
runner.on('end', () => {
console.log('end: %d/%d', passes, passes + failures);
const mochaFixture = document.getElementById('mocha');
if (mochaFixture) {
var html = `<div style="color: ${failures ? 'red' : 'green'}">`;
html += `${passes}/${failures}${passes}`;
html += ' tests passed</div>';
mochaFixture.innerHTML = html;
}
});
});
})();