☕️ Classic, reliable, trusted test framework for Node.js and the browser
stats element
Tj Holowaychukf4b74913e851
diff --git a/lib/reporters/html.js b/lib/reporters/html.jsindex ce220ae2..75a32110 100644--- a/lib/reporters/html.js+++ b/lib/reporters/html.js@@ -21,15 +21,24 @@ exports = module.exports = HTML;function HTML(runner) {Base.call(this, runner);+ // TODO: clean up+var self = this, stats = this.stats, total = runner.total, root = document.getElementById('mocha')- , stack = [root];+ , stack = [root]+ , stat = document.createElement('div');++ stat.innerHTML = '<ul id="stats">'+ + '<li class="passes">passes: <em>0</em></li>'+ + '<li class="failures">failures: <em>0</em></li>'+ + '</ul>';if (!root) error('#mocha div missing, add it to your document');document.body.appendChild(root);+ document.body.appendChild(stat);runner.on('suite', function(suite){if (suite.root) return;@@ -55,6 +64,7 @@ function HTML(runner) {});runner.on('test end', function(test){+ console.log(stats);// testvar el = document.createElement('div');el.setAttribute('class', 'test ' + (test.passed ? 'pass' : 'fail'));diff --git a/mocha.js b/mocha.jsindex daefd95b..7ce59dc4 100644--- a/mocha.js+++ b/mocha.js@@ -762,15 +762,24 @@ exports = module.exports = HTML;function HTML(runner) {Base.call(this, runner);+ // TODO: clean up+var self = this, stats = this.stats, total = runner.total, root = document.getElementById('mocha')- , stack = [root];+ , stack = [root]+ , stat = document.createElement('div');++ stat.innerHTML = '<ul id="stats">'+ + '<li class="passes">passes: <em>0</em></li>'+ + '<li class="failures">failures: <em>0</em></li>'+ + '</ul>';if (!root) error('#mocha div missing, add it to your document');document.body.appendChild(root);+ document.body.appendChild(stat);runner.on('suite', function(suite){if (suite.root) return;@@ -796,6 +805,7 @@ function HTML(runner) {});runner.on('test end', function(test){+ console.log(stats);// testvar el = document.createElement('div');el.setAttribute('class', 'test ' + (test.passed ? 'pass' : 'fail'));