Skip to content

armgit / mocha

Public Imported from GitHub
0

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

Release 0.8.2

Tj Holowaychuk2a90cd4eb292
diff --git a/History.md b/History.md
index 22c5dac0..bafe2f47 100644
--- a/History.md
+++ b/History.md
@@ -1,4 +1,11 @@
+0.8.2 / 2012-01-05
+==================
+
+ * Added test-case context support. Closes #113
+ * Fixed exit status. Closes #187
+ * Update commander. Closes #190
+
0.8.1 / 2011-12-30
==================
diff --git a/lib/mocha.js b/lib/mocha.js
index 4b2cfa1b..903bc342 100644
--- a/lib/mocha.js
+++ b/lib/mocha.js
@@ -9,7 +9,7 @@
* Library version.
*/
-exports.version = '0.8.1';
+exports.version = '0.9.0';
exports.utils = require('./utils');
exports.interfaces = require('./interfaces');
diff --git a/mocha.js b/mocha.js
index 27994aba..4288511e 100644
--- a/mocha.js
+++ b/mocha.js
@@ -688,7 +688,7 @@ require.register("mocha.js", function(module, exports, require){
* Library version.
*/
-exports.version = '0.8.1';
+exports.version = '0.9.0';
exports.utils = require('./utils');
exports.interfaces = require('./interfaces');
@@ -2015,6 +2015,7 @@ function Runnable(title, fn) {
this.async = fn && fn.length;
this.sync = ! this.async;
this._timeout = 2000;
+ this.context = this;
}
/**
@@ -2092,6 +2093,7 @@ Runnable.prototype.run = function(fn){
var self = this
, ms = this.timeout()
, start = new Date
+ , ctx = this.context
, finished
, emitted;
@@ -2126,7 +2128,7 @@ Runnable.prototype.run = function(fn){
// async
if (this.async) {
try {
- this.fn(function(err){
+ this.fn.call(ctx, function(err){
if (err instanceof Error) return done(err);
if (null != err) return done(new Error('done() invoked with non-Error: ' + err));
done();
@@ -2139,7 +2141,7 @@ Runnable.prototype.run = function(fn){
// sync
try {
- if (!this.pending) this.fn();
+ if (!this.pending) this.fn.call(ctx);
this.duration = new Date - start;
fn();
} catch (err) {
@@ -2310,6 +2312,7 @@ Runner.prototype.hook = function(name, fn){
var hook = hooks[i];
if (!hook) return fn();
self.currentRunnable = hook;
+ hook.context = self.test;
self.emit('hook', hook);
diff --git a/package.json b/package.json
index c95ec7bf..1eeff8d4 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "mocha"
- , "version": "0.8.1"
+ , "version": "0.9.0"
, "description": "simple, flexible, fun test framework"
, "keywords": ["test", "bdd", "tdd", "tap"]
, "author": "TJ Holowaychuk <[email protected]>"