Skip to content

Commit

Permalink
Merge pull request #370 from adomokos/add_pending_count
Browse files Browse the repository at this point in the history
Displaying the number of pending specs
  • Loading branch information
tj committed Apr 11, 2012
2 parents d5a3539 + 141ba20 commit f3eeab1
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions lib/reporters/base.js
Expand Up @@ -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;
Expand Down Expand Up @@ -237,6 +237,10 @@ function Base(runner) {
stats.end = new Date;
stats.duration = new Date - stats.start;
});

runner.on('pending', function(){
stats.pending++;
});
}

/**
Expand All @@ -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();
};

Expand Down

0 comments on commit f3eeab1

Please sign in to comment.