Skip to content

armgit / mocha

Public Imported from GitHub
0

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

duration in seconds

Tj Holowaychuke349297db4aa
diff --git a/lib/reporters/html.js b/lib/reporters/html.js
index b8d4b416..c84d8eb0 100644
--- a/lib/reporters/html.js
+++ b/lib/reporters/html.js
@@ -18,7 +18,7 @@ exports = module.exports = HTML;
var statsTemplate = '<ul id="stats">'
+ '<li class="passes">passes: <em>0</em></li>'
+ '<li class="failures">failures: <em>0</em></li>'
- + '<li class="duration">duration: <em>0</em>ms</li>'
+ + '<li class="duration">duration: <em>0</em>s</li>'
+ '</ul>';
/**
@@ -67,9 +67,10 @@ function HTML(runner) {
runner.on('test end', function(test){
// update stats
+ var ms = new Date - stats.start;
stat.find('.passes em').text(stats.passes);
stat.find('.failures em').text(stats.failures);
- stat.find('.duration em').text(new Date - stats.start);
+ stat.find('.duration em').text((ms / 1000).toFixed(2));
// test
var str = test.passed ? 'pass' : 'fail';
diff --git a/mocha.js b/mocha.js
index e1e7c4d2..8dfc32a4 100644
--- a/mocha.js
+++ b/mocha.js
@@ -759,7 +759,7 @@ exports = module.exports = HTML;
var statsTemplate = '<ul id="stats">'
+ '<li class="passes">passes: <em>0</em></li>'
+ '<li class="failures">failures: <em>0</em></li>'
- + '<li class="duration">duration: <em>0</em>ms</li>'
+ + '<li class="duration">duration: <em>0</em>s</li>'
+ '</ul>';
/**
@@ -808,9 +808,10 @@ function HTML(runner) {
runner.on('test end', function(test){
// update stats
+ var ms = new Date - stats.start;
stat.find('.passes em').text(stats.passes);
stat.find('.failures em').text(stats.failures);
- stat.find('.duration em').text(new Date - stats.start);
+ stat.find('.duration em').text((ms / 1000).toFixed(2));
// test
var str = test.passed ? 'pass' : 'fail';