Skip to content

Commit

Permalink
Update final stats in on('end') when an after hook failed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stepan Riha committed Apr 2, 2012
1 parent 4ef434b commit 74d19a9
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/reporters/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function HTML(runner) {
, stack = [root]
, progress
, ctx
, tests = { passed: 0, failed: 0, pending: 0};

if (canvas.getContext) {
ctx = canvas.getContext('2d');
Expand Down Expand Up @@ -174,13 +175,6 @@ function HTML(runner) {
});

runner.on('suite end', function(suite){
if (suite.root) {
text(currentTest, '');
currentTest.appendChild(fragment('<span class="totals"><strong class="passed">%s</strong>/<strong class="failed">%s</strong>/<strong class="pending">%s</strong></span>',
suite.passed||0, suite.failed||0, suite.pending||0));
return;
}

if(suite.parent.root) {
// insert space between top-level suites
dots.appendChild(document.createTextNode(' '));
Expand All @@ -189,6 +183,13 @@ function HTML(runner) {
stack.shift();
});

// Update final stats
runner.on('end', function() {
text(currentTest, '');
currentTest.appendChild(fragment('<span class="totals"><strong class="passed">%s</strong>/<strong class="failed">%s</strong>/<strong class="pending">%s</strong></span>',
tests.passed, tests.failed, tests.pending));
});

runner.on('test', function(test) {
text(currentTest, "Executing: " + test.fullTitle());
})
Expand Down Expand Up @@ -247,6 +248,8 @@ function HTML(runner) {
propageTestState(test.parent, state);
}

tests[state] += 1;

dots.appendChild(fragment('<span class="%s">•</span>', state));

// toggle code
Expand Down

0 comments on commit 74d19a9

Please sign in to comment.