Skip to content

armgit / mocha

Public Imported from GitHub
0

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

build

TJ Holowaychukc50a637e3725
diff --git a/mocha.js b/mocha.js
index ea6485f1..a7356dbd 100644
--- a/mocha.js
+++ b/mocha.js
@@ -1222,7 +1222,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;
@@ -1266,6 +1266,10 @@ function Base(runner) {
stats.end = new Date;
stats.duration = new Date - stats.start;
});
+
+ runner.on('pending', function(){
+ stats.pending++;
+ });
}
/**
@@ -1277,17 +1281,26 @@ function Base(runner) {
Base.prototype.epilogue = function(){
var stats = this.stats
- , fmt;
+ , fmt
+ , tests;
console.log();
+ function pluralize(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,
+ pluralize(this.runner.total));
+
Base.list(this.failures);
console.error();
return;
@@ -1295,10 +1308,22 @@ Base.prototype.epilogue = function(){
// 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,
+ pluralize(stats.tests),
+ stats.duration);
+
+ // pending
+ if (stats.pending) {
+ fmt = color('pending', ' •')
+ + color('pending', ' %d %s pending');
+
+ console.log(fmt, stats.pending, pluralize(stats.pending));
+ }
+
console.log();
};
@@ -3990,15 +4015,16 @@ process.nextTick = (function(){
var timeouts = []
, name = 'mocha-zero-timeout'
+ window.addEventListener('message', function(e){
+ if (e.source == window && e.data == name) {
+ if (e.stopPropagation) e.stopPropagation();
+ if (timeouts.length) timeouts.shift()();
+ }
+ }, true);
+
return function(fn){
timeouts.push(fn);
window.postMessage(name, '*');
- window.addEventListener('message', function(e){
- if (e.source == window && e.data == name) {
- if (e.stopPropagation) e.stopPropagation();
- if (timeouts.length) timeouts.shift()();
- }
- }, true);
}
})();
@@ -4109,4 +4135,4 @@ window.mocha = require('mocha');
return runner.run(fn);
};
})();
-})();
+})();
\ No newline at end of file