' +
@@ -62,18 +63,35 @@ function HTML(runner, options) {
var stats = this.stats;
var stat = fragment(statsTemplate);
var items = stat.getElementsByTagName('li');
- var passes = items[1].getElementsByTagName('em')[0];
- var passesLink = items[1].getElementsByTagName('a')[0];
- var failures = items[2].getElementsByTagName('em')[0];
- var failuresLink = items[2].getElementsByTagName('a')[0];
- var duration = items[3].getElementsByTagName('em')[0];
+ const resultIndex = 0;
+ const progressIndex = 1;
+ const passesIndex = 2;
+ const failuresIndex = 3;
+ const durationIndex = 4;
+ /** Stat item containing the root suite pass or fail indicator (hasFailures ? '✖' : '✓') */
+ var resultIndicator = items[resultIndex];
+ /** Passes text and count */
+ const passesStat = items[passesIndex];
+ /** Stat item containing the pass count (not the word, just the number) */
+ const passesCount = passesStat.getElementsByTagName('em')[0];
+ /** Stat item linking to filter to show only passing tests */
+ const passesLink = passesStat.getElementsByTagName('a')[0];
+ /** Failures text and count */
+ const failuresStat = items[failuresIndex];
+ /** Stat item containing the failure count (not the word, just the number) */
+ const failuresCount = failuresStat.getElementsByTagName('em')[0];
+ /** Stat item linking to filter to show only failing tests */
+ const failuresLink = failuresStat.getElementsByTagName('a')[0];
+ /** Stat item linking to the duration time (not the word or unit, just the number) */
+ var duration = items[durationIndex].getElementsByTagName('em')[0];
var report = fragment('
');
var stack = [report];
- var progressText = items[0].getElementsByTagName('div')[0];
- var progressBar = items[0].getElementsByTagName('progress')[0];
+ var progressText = items[progressIndex].getElementsByTagName('div')[0];
+ var progressBar = items[progressIndex].getElementsByTagName('progress')[0];
var progressRing = [
- items[0].getElementsByClassName('ring-flatlight')[0],
- items[0].getElementsByClassName('ring-highlight')[0]];
+ items[progressIndex].getElementsByClassName('ring-flatlight')[0],
+ items[progressIndex].getElementsByClassName('ring-highlight')[0]
+ ];
var progressRingRadius = null; // computed CSS unavailable now, so set later
var root = document.getElementById('mocha');
@@ -127,6 +145,10 @@ function HTML(runner, options) {
runner.on(EVENT_SUITE_END, function (suite) {
if (suite.root) {
+ if (stats.failures === 0) {
+ text(resultIndicator, '✓');
+ stat.className += ' pass';
+ }
updateStats();
return;
}
@@ -147,6 +169,10 @@ function HTML(runner, options) {
});
runner.on(EVENT_TEST_FAIL, function (test) {
+ // Update stat items
+ text(resultIndicator, '✖');
+ stat.className += ' fail';
+
var el = fragment(
'