Skip to content

armgit / mocha

Public Imported from GitHub
0

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

Add total number of passes and failures to TAP

Forbes Lindesay61cec6468072
diff --git a/lib/reporters/tap.js b/lib/reporters/tap.js
index 8f8fc5f8..bcb9a3e0 100644
--- a/lib/reporters/tap.js
+++ b/lib/reporters/tap.js
@@ -25,7 +25,9 @@ function TAP(runner) {
var self = this
, stats = this.stats
- , n = 1;
+ , n = 1
+ , passes = 0
+ , failures = 1;
runner.on('start', function(){
var total = runner.grepTotal(runner.suite);
@@ -41,13 +43,21 @@ function TAP(runner) {
});
runner.on('pass', function(test){
+ passes++;
console.log('ok %d %s', n, title(test));
});
runner.on('fail', function(test, err){
+ failures++;
console.log('not ok %d %s', n, title(test));
console.log(err.stack.replace(/^/gm, ' '));
});
+
+ runner.on('end', function () {
+ console.log('# tests ' + (passes + failures));
+ console.log('# pass ' + passes);
+ console.log('# fail ' + failures);
+ });
}
/**