Comparing version 0.1.0 to 0.2.0
0.2.0 / 2011-11-30 | ||
================== | ||
* Added `--globals <names>` to specify accepted globals. Closes #99 | ||
* Fixed funky highlighting of messages. Closes #97 | ||
* Fixed `mocha-debug(1)`. Closes #232 | ||
* Fixed growl total, use runner.total | ||
0.1.0 / 2011-11-29 | ||
@@ -3,0 +11,0 @@ ================== |
@@ -12,3 +12,3 @@ | ||
exports.version = '0.1.0'; | ||
exports.version = '0.2.0'; | ||
@@ -15,0 +15,0 @@ exports.interfaces = require('./interfaces'); |
@@ -117,8 +117,9 @@ | ||
// msg | ||
var stack = test.err.stack | ||
, index = stack.indexOf('at') | ||
var err = test.err | ||
, stack = err.stack | ||
, index = stack.indexOf(err.message) + err.message.length | ||
, msg = stack.slice(0, index); | ||
// indent stack trace without msg | ||
stack = stack.slice(index) | ||
stack = stack.slice(index + 1) | ||
.replace(/^/gm, ' '); | ||
@@ -125,0 +126,0 @@ |
@@ -37,8 +37,9 @@ | ||
var self = this; | ||
this._globals = []; | ||
this.suite = suite; | ||
this.total = suite.total(); | ||
this.globals = Object.keys(global).concat(['errno']); | ||
this.on('test end', function(test){ self.checkGlobals(test); }); | ||
this.on('hook end', function(hook){ self.checkGlobals(hook); }); | ||
this.grep(/.*/); | ||
this.globals(Object.keys(global).concat(['errno'])); | ||
} | ||
@@ -66,2 +67,17 @@ | ||
/** | ||
* Allow the given `arr` of globals. | ||
* | ||
* @param {Array} arr | ||
* @return {Runner} for chaining | ||
* @api public | ||
*/ | ||
Runner.prototype.globals = function(arr){ | ||
arr.forEach(function(arr){ | ||
this._globals.push(arr); | ||
}, this); | ||
return this; | ||
}; | ||
/** | ||
* Check for global variable leaks. | ||
@@ -74,6 +90,6 @@ * | ||
var leaks = Object.keys(global).filter(function(key){ | ||
return !~this.globals.indexOf(key); | ||
return !~this._globals.indexOf(key); | ||
}, this); | ||
this.globals = this.globals.concat(leaks); | ||
this._globals = this._globals.concat(leaks); | ||
@@ -80,0 +96,0 @@ if (leaks.length > 1) { |
72
mocha.js
@@ -324,5 +324,9 @@ | ||
* TDD-style interface: | ||
* | ||
* | ||
* suite('Array', function(){ | ||
* suite('#indexOf()', function(){ | ||
* suiteSetup(function(){ | ||
* | ||
* }); | ||
* | ||
* test('should return -1 when not present', function(){ | ||
@@ -335,5 +339,9 @@ * | ||
* }); | ||
* | ||
* suiteTeardown(function(){ | ||
* | ||
* }); | ||
* }); | ||
* }); | ||
* | ||
* | ||
*/ | ||
@@ -355,3 +363,3 @@ | ||
/** | ||
* Execute before each test case. | ||
* Execute after each test case. | ||
*/ | ||
@@ -364,2 +372,18 @@ | ||
/** | ||
* Execute before the suite. | ||
*/ | ||
context.suiteSetup = function(fn){ | ||
suites[0].beforeAll(fn); | ||
}; | ||
/** | ||
* Execute after the suite. | ||
*/ | ||
context.suiteTeardown = function(fn){ | ||
suites[0].afterAll(fn); | ||
}; | ||
/** | ||
* Describe a "suite" with the given `title` | ||
@@ -369,3 +393,3 @@ * and callback `fn` containing nested suites | ||
*/ | ||
context.suite = function(title, fn){ | ||
@@ -404,3 +428,3 @@ var suite = Suite.create(suites[0], title); | ||
exports.version = '0.0.6'; | ||
exports.version = '0.2.0'; | ||
@@ -533,8 +557,9 @@ exports.interfaces = require('./interfaces'); | ||
// msg | ||
var stack = test.err.stack | ||
, index = stack.indexOf('at') | ||
var err = test.err | ||
, stack = err.stack | ||
, index = stack.indexOf(err.message) + err.message.length | ||
, msg = stack.slice(0, index); | ||
// indent stack trace without msg | ||
stack = stack.slice(index) | ||
stack = stack.slice(index + 1) | ||
.replace(/^/gm, ' '); | ||
@@ -564,2 +589,3 @@ | ||
if (!runner) return; | ||
this.runner = runner; | ||
@@ -625,3 +651,3 @@ runner.on('start', function(){ | ||
console.error(fmt, stats.failures, stats.tests); | ||
console.error(fmt, stats.failures, this.runner.total); | ||
Base.list(this.failures); | ||
@@ -1388,3 +1414,3 @@ console.error(); | ||
runner.on('test', function(test){ | ||
process.stdout.write(indent() + color('pass', test.title + ': ')); | ||
process.stdout.write(indent() + color('pass', ' ◦ ' + test.title + ': ')); | ||
}); | ||
@@ -1555,3 +1581,3 @@ | ||
var self = this | ||
, ms = this._timeout | ||
, ms = this.timeout() | ||
, start = new Date | ||
@@ -1565,3 +1591,3 @@ , finished | ||
timer = setTimeout(function(){ | ||
fn(new Error('timeout of ' + ms + 'ms exceeded')); | ||
done(new Error('timeout of ' + ms + 'ms exceeded')); | ||
}, ms); | ||
@@ -1645,8 +1671,9 @@ } | ||
var self = this; | ||
this._globals = []; | ||
this.suite = suite; | ||
this.total = suite.total(); | ||
this.globals = Object.keys(global).concat(['errno']); | ||
this.on('test end', function(test){ self.checkGlobals(test); }); | ||
this.on('hook end', function(hook){ self.checkGlobals(hook); }); | ||
this.grep(/.*/); | ||
this.globals(Object.keys(global).concat(['errno'])); | ||
} | ||
@@ -1676,2 +1703,17 @@ | ||
/** | ||
* Allow the given `arr` of globals. | ||
* | ||
* @param {Array} arr | ||
* @return {Runner} for chaining | ||
* @api public | ||
*/ | ||
Runner.prototype.globals = function(arr){ | ||
arr.forEach(function(arr){ | ||
this._globals.push(arr); | ||
}, this); | ||
return this; | ||
}; | ||
/** | ||
* Check for global variable leaks. | ||
@@ -1684,6 +1726,6 @@ * | ||
var leaks = Object.keys(global).filter(function(key){ | ||
return !~this.globals.indexOf(key); | ||
return !~this._globals.indexOf(key); | ||
}, this); | ||
this.globals = this.globals.concat(leaks); | ||
this._globals = this._globals.concat(leaks); | ||
@@ -1690,0 +1732,0 @@ if (leaks.length > 1) { |
{ | ||
"name": "mocha" | ||
, "version": "0.1.0" | ||
, "version": "0.2.0" | ||
, "description": "Test framework inspired by JSpec, Expresso, & Qunit" | ||
@@ -5,0 +5,0 @@ , "keywords": ["test", "bdd", "tdd", "tap"] |
@@ -20,3 +20,8 @@ | ||
}); | ||
it('should pass when accepted', function(){ | ||
okGlobalA = 1; | ||
okGlobalB = 1; | ||
}) | ||
afterEach(function(){ | ||
@@ -23,0 +28,0 @@ // uncomment to test |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
129316
4659