☕️ Classic, reliable, trusted test framework for Node.js and the browser
Release 0.10.2
TJ Holowaychuk52f9ddaa1d9b
diff --git a/History.md b/History.mdindex e820a8af..9a4d96ea 100644--- a/History.md+++ b/History.md@@ -1,4 +1,11 @@+0.10.2 / 2012-01-21+==================++ * Fixed suite count in reporter stats. Closes #222+ * Fixed `done()` after timeout error reporting [Phil Sung]+ * Changed the 0-based errors to 1+0.10.1 / 2012-01-17==================diff --git a/lib/mocha.js b/lib/mocha.jsindex 85f7da3c..47af8a6e 100644--- a/lib/mocha.js+++ b/lib/mocha.js@@ -9,7 +9,7 @@* Library version.*/-exports.version = '0.10.1';+exports.version = '0.11.0';exports.utils = require('./utils');exports.interfaces = require('./interfaces');diff --git a/mocha.css b/mocha.cssindex f136f796..802b3e48 100644--- a/mocha.css+++ b/mocha.css@@ -40,6 +40,10 @@ body {color: #888;}+#mocha .test.pending:hover h2::after {+ content: '(pending)';+}+#mocha .test.pass::before {content: '✓';font-size: 12px;diff --git a/mocha.js b/mocha.jsindex 1fa451aa..c109790f 100644--- a/mocha.js+++ b/mocha.js@@ -789,7 +789,7 @@ require.register("mocha.js", function(module, exports, require){* Library version.*/-exports.version = '0.10.1';+exports.version = '0.11.0';exports.utils = require('./utils');exports.interfaces = require('./interfaces');@@ -942,7 +942,7 @@ exports.list = function(failures){stack = stack.slice(index + 1).replace(/^/gm, ' ');- console.error(fmt, i, test.fullTitle(), msg, stack);+ console.error(fmt, (i + 1), test.fullTitle(), msg, stack);});};@@ -972,7 +972,7 @@ function Base(runner) {runner.on('suite', function(suite){stats.suites = stats.suites || 0;- stats.suites++;+ suite.root || stats.suites++;});runner.on('test end', function(test){@@ -1298,9 +1298,9 @@ function HTML(runner) {// toggle codeel.find('h2').toggle(function(){- pre.slideDown('fast');+ pre && pre.slideDown('fast');}, function(){- pre.slideUp('fast');+ pre && pre.slideUp('fast');});// code@@ -1654,7 +1654,7 @@ function List(runner) {runner.on('fail', function(test, err){cursor.CR();- console.log(color('fail', ' %d) %s'), n++, test.fullTitle());+ console.log(color('fail', ' %d) %s'), ++n, test.fullTitle());});runner.on('end', self.epilogue.bind(self));@@ -2115,6 +2115,7 @@ function Runnable(title, fn) {this.async = fn && fn.length;this.sync = ! this.async;this._timeout = 2000;+ this.timedOut = false;this.context = this;}@@ -2178,6 +2179,7 @@ Runnable.prototype.resetTimeout = function(){if (ms) {this.timer = setTimeout(function(){self.callback(new Error('timeout of ' + ms + 'ms exceeded'));+ self.timedOut = true;}, ms);}};@@ -2202,6 +2204,7 @@ Runnable.prototype.run = function(fn){if (ms) {this.timer = setTimeout(function(){done(new Error('timeout of ' + ms + 'ms exceeded'));+ self.timedOut = true;}, ms);}}@@ -2215,6 +2218,7 @@ Runnable.prototype.run = function(fn){// finishedfunction done(err) {+ if (self.timedOut) return;if (finished) return multiple();self.clearTimeout();self.duration = new Date - start;@@ -2331,6 +2335,7 @@ Runner.prototype.grep = function(re){*/Runner.prototype.globals = function(arr){+ if (0 == arguments.length) return this._globals;debug('globals %j', arr);utils.forEach(arr, function(arr){this._globals.push(arr);@@ -2388,7 +2393,6 @@ Runner.prototype.fail = function(test, err){*/Runner.prototype.failHook = function(hook, err){- ++this.failures;this.fail(hook, err);this.emit('end');};@@ -2624,6 +2628,32 @@ Runner.prototype.runSuite = function(suite, fn){});};+/**+ * Handle uncaught exceptions.+ *+ * @param {Error} err+ * @api private+ */++Runner.prototype.uncaught = function(err){+ debug('uncaught exception');+ var runnable = this.currentRunnable;+ if (runnable.failed) return;+ runnable.clearTimeout();+ err.uncaught = true;+ this.fail(runnable, err);++ // recover from test+ if ('test' == runnable.type) {+ this.emit('test end', runnable);+ this.hookUp('afterEach', this.next);+ return;+ }++ // bail on hooks+ this.emit('end');+};+/*** Run the root suite and invoke `fn(failures)`* on completion.@@ -2640,9 +2670,9 @@ Runner.prototype.run = function(fn){debug('start');// callback- self.on('end', function(){+ this.on('end', function(){debug('end');- process.removeListener('uncaughtException', uncaught);+ process.removeListener('uncaughtException', this.uncaught);fn(self.failures);});@@ -2654,25 +2684,9 @@ Runner.prototype.run = function(fn){});// uncaught exception- function uncaught(err){- var runnable = self.currentRunnable;- debug('uncaught exception');- if (runnable.failed) return;- runnable.clearTimeout();- err.uncaught = true;- self.fail(runnable, err);-- // recover from test- if ('test' == runnable.type) {- self.emit('test end', runnable);- self.hookUp('afterEach', self.next);- // bail on hooks- } else {- self.emit('end');- }- }-- process.on('uncaughtException', uncaught);+ process.on('uncaughtException', function(err){+ self.uncaught(err);+ });return this;};diff --git a/package.json b/package.jsonindex 88c578f2..be08f243 100644--- a/package.json+++ b/package.json@@ -1,6 +1,6 @@{"name": "mocha"- , "version": "0.10.1"+ , "version": "0.10.2", "description": "simple, flexible, fun test framework", "keywords": ["test", "bdd", "tdd", "tap"], "author": "TJ Holowaychuk <[email protected]>"