Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

Fix % always 0 in HTML reporter updateStats() accesses this.total, but this === the global object (window) if not specified explicitly. Also added a missing update when all tests end.

Avi Vahl966ab86017d4
diff --git a/lib/reporters/html.js b/lib/reporters/html.js
index 5167d18b..e4983281 100644
--- a/lib/reporters/html.js
+++ b/lib/reporters/html.js
@@ -125,6 +125,7 @@ function HTML(runner) {
runner.on('suite end', function(suite) {
if (suite.root) {
+ updateStats.call(this);
return;
}
stack.shift();
@@ -137,7 +138,7 @@ function HTML(runner) {
var el = fragment(markup, test.speed, test.title, test.duration, url);
self.addCodeToggle(el, test.body);
appendToStack(el);
- updateStats();
+ updateStats.call(this);
});
runner.on('fail', function(test) {
@@ -177,13 +178,13 @@ function HTML(runner) {
self.addCodeToggle(el, test.body);
appendToStack(el);
- updateStats();
+ updateStats.call(this);
});
runner.on('pending', function(test) {
var el = fragment('<li class="test pass pending"><h2>%e</h2></li>', test.title);
appendToStack(el);
- updateStats();
+ updateStats.call(this);
});
function appendToStack(el) {