Permalink
Browse files

Merge pull request #370 from adomokos/add_pending_count

Displaying the number of pending specs
  • Loading branch information...
2 parents d5a3539 + 141ba20 commit f3eeab15e29a548562a6d6f31441017642edd0d6 @tj tj committed Apr 11, 2012
Showing with 32 additions and 6 deletions.
  1. +32 −6 lib/reporters/base.js
View
@@ -193,7 +193,7 @@ exports.list = function(failures){
function Base(runner) {
var self = this
- , stats = this.stats = { suites: 0, tests: 0, passes: 0, failures: 0 }
+ , stats = this.stats = { suites: 0, tests: 0, passes: 0, pending: 0, failures: 0 }
, failures = this.failures = [];
if (!runner) return;
@@ -237,6 +237,10 @@ function Base(runner) {
stats.end = new Date;
stats.duration = new Date - stats.start;
});
+
+ runner.on('pending', function(){
+ stats.pending++;
+ });
}
/**
@@ -248,28 +252,50 @@ function Base(runner) {
Base.prototype.epilogue = function(){
var stats = this.stats
- , fmt;
+ , fmt
+ , tests;
console.log();
+ var pluralizeTest = function(n) {
+ return 1 == n ? 'test' : 'tests';
+ }
+
// failure
if (stats.failures) {
fmt = color('bright fail', '')
- + color('fail', ' %d of %d tests failed')
+ + color('fail', ' %d of %d %s failed')
+ color('light', ':')
- console.error(fmt, stats.failures, this.runner.total);
+ console.error(fmt,
+ stats.failures,
+ this.runner.total,
+ pluralizeTest(this.runner.total));
Base.list(this.failures);
console.error();
return;
}
// pass
fmt = color('bright pass', '')
- + color('green', ' %d tests complete')
+ + color('green', ' %d %s complete')
+ color('light', ' (%dms)');
- console.log(fmt, stats.tests || 0, stats.duration);
+ console.log(fmt,
+ stats.tests || 0,
+ pluralizeTest(stats.tests),
+ stats.duration);
+
+ // pending
+ if (stats.pending) {
+ fmt = color('pending', '')
+ + color('pending', ' %d %s pending');
+
+ console.log(fmt,
+ stats.pending,
+ pluralizeTest(stats.pending));
+ }
+
console.log();
};

0 comments on commit f3eeab1

Please sign in to comment.