Skip to content

armgit / mocha

Public Imported from GitHub
0

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

Release 0.4.0

Tj Holowaychuk92d7eedc925d
diff --git a/History.md b/History.md
index 117fd05d..0b574032 100644
--- a/History.md
+++ b/History.md
@@ -1,4 +1,14 @@
+0.4.0 / 2011-12-14
+==================
+
+ * Added support for test-specific timeouts via `this.timeout(0)`. Closes #134
+ * Added guillermo's client-side EventEmitter. Closes #132
+ * Added progress indicator to the HTML reporter
+ * Fixed slow browser tests. Closes #135
+ * Fixed "suite" color for light terminals
+ * Fixed `require()` leak spotted by [guillermo]
+
0.3.6 / 2011-12-09
==================
diff --git a/lib/mocha.js b/lib/mocha.js
index 07d103d7..495bfd20 100644
--- a/lib/mocha.js
+++ b/lib/mocha.js
@@ -9,7 +9,7 @@
* Library version.
*/
-exports.version = '0.3.6';
+exports.version = '0.4.0';
exports.interfaces = require('./interfaces');
exports.reporters = require('./reporters');
diff --git a/mocha.js b/mocha.js
index e5ef7fda..fb2ecc64 100644
--- a/mocha.js
+++ b/mocha.js
@@ -688,7 +688,7 @@ require.register("mocha.js", function(module, exports, require){
* Library version.
*/
-exports.version = '0.3.6';
+exports.version = '0.4.0';
exports.interfaces = require('./interfaces');
exports.reporters = require('./reporters');
@@ -1745,15 +1745,32 @@ function TAP(runner) {
++n;
});
+ runner.on('pending', function(test){
+ console.log('ok %d %s # SKIP -', n, title(test));
+ });
+
runner.on('pass', function(test){
- console.log('ok %d %s', n, test.fullTitle());
+ console.log('ok %d %s', n, title(test));
});
runner.on('fail', function(test, err){
- console.log('not ok %d %s', n, test.fullTitle());
+ console.log('not ok %d %s', n, title(test));
console.log(err.stack.replace(/^/gm, ' '));
});
}
+
+/**
+ * Return a TAP-safe title of `test`
+ *
+ * @param {Object} test
+ * @return {String}
+ * @api private
+ */
+
+function title(test) {
+ return test.fullTitle().replace(/#/g, '');
+}
+
}); // module: reporters/tap.js
require.register("runnable.js", function(module, exports, require){
@@ -1807,6 +1824,7 @@ Runnable.prototype.timeout = function(ms){
if (0 == arguments.length) return this._timeout;
debug('timeout %d', ms);
this._timeout = ms;
+ if (this.timer) this.resetTimeout();
return this;
};
@@ -1832,6 +1850,24 @@ Runnable.prototype.clearTimeout = function(){
clearTimeout(this.timer);
};
+/**
+ * Reset the timeout.
+ *
+ * @api private
+ */
+
+Runnable.prototype.resetTimeout = function(){
+ var self = this
+ , ms = this.timeout();
+
+ this.clearTimeout();
+ if (ms) {
+ this.timer = setTimeout(function(){
+ self.callback(new Error('timeout of ' + ms + 'ms exceeded'));
+ }, ms);
+ }
+};
+
/**
* Run the test and invoke `fn(err)`.
*
@@ -1848,9 +1884,11 @@ Runnable.prototype.run = function(fn){
// timeout
if (this.async) {
- this.timer = setTimeout(function(){
- done(new Error('timeout of ' + ms + 'ms exceeded'));
- }, ms);
+ if (ms) {
+ this.timer = setTimeout(function(){
+ done(new Error('timeout of ' + ms + 'ms exceeded'));
+ }, ms);
+ }
}
// called multiple times
@@ -1869,6 +1907,9 @@ Runnable.prototype.run = function(fn){
fn(err);
}
+ // for .resetTimeout()
+ this.callback = done;
+
// async
if (this.async) {
try {
diff --git a/package.json b/package.json
index 31ccc549..c71b3eae 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "mocha"
- , "version": "0.3.6"
+ , "version": "0.4.0"
, "description": "Test framework inspired by JSpec, Expresso, & Qunit"
, "keywords": ["test", "bdd", "tdd", "tap"]
, "bin": { "mocha": "./bin/mocha" }