Comparing version 0.7.1 to 0.8.0
140
_mocha.js
@@ -689,3 +689,3 @@ | ||
exports.version = '0.7.0'; | ||
exports.version = '0.8.0'; | ||
@@ -835,3 +835,3 @@ exports.utils = require('./utils'); | ||
var err = test.err | ||
, stack = err.stack | ||
, stack = err.stack || err.message | ||
, message = err.message || '' | ||
@@ -1217,2 +1217,6 @@ , index = stack.indexOf(message) + message.length | ||
/** | ||
* Display error `msg`. | ||
*/ | ||
function error(msg) { | ||
@@ -1257,2 +1261,3 @@ $('<div id="error">' + msg + '</div>').appendTo('body'); | ||
exports.JSONStream = require('./json-stream'); | ||
exports.XUnit = require('./xunit') | ||
@@ -1835,2 +1840,9 @@ }); // module: reporters/index.js | ||
/** | ||
* Initialize a new `Teamcity` reporter. | ||
* | ||
* @param {Runner} runner | ||
* @api public | ||
*/ | ||
function Teamcity(runner) { | ||
@@ -1845,15 +1857,15 @@ Base.call(this, runner); | ||
runner.on('test', function(test) { | ||
console.log("##teamcity[testStarted name='%s']", test.fullTitle()); | ||
console.log("##teamcity[testStarted name='%s']", escape(test.fullTitle())); | ||
}); | ||
runner.on('fail', function(test, err) { | ||
console.log("##teamcity[testFailed name='%s' message='%s']", test.fullTitle(), err.message); | ||
console.log("##teamcity[testFailed name='%s' message='%s']", escape(test.fullTitle()), escape(err.message)); | ||
}); | ||
runner.on('pending', function(test) { | ||
console.log("##teamcity[testIgnored name='%s' message='pending']", test.fullTitle()); | ||
console.log("##teamcity[testIgnored name='%s' message='pending']", escape(test.fullTitle())); | ||
}); | ||
runner.on('test end', function(test) { | ||
console.log("##teamcity[testFinished name='%s' duration='%s']", test.fullTitle(), test.duration); | ||
console.log("##teamcity[testFinished name='%s' duration='%s']", escape(test.fullTitle()), test.duration); | ||
}); | ||
@@ -1866,4 +1878,117 @@ | ||
/** | ||
* Escape the given `str`. | ||
*/ | ||
function escape(str) { | ||
return str.replace(/'/g, "|'"); | ||
} | ||
}); // module: reporters/teamcity.js | ||
require.register("reporters/xunit.js", function(module, exports, require){ | ||
/** | ||
* Module dependencies. | ||
*/ | ||
var Base = require('./base') | ||
, utils = require('../utils') | ||
, escape = utils.escape; | ||
/** | ||
* Expose `XUnit`. | ||
*/ | ||
exports = module.exports = XUnit; | ||
/** | ||
* Initialize a new `XUnit` reporter. | ||
* | ||
* @param {Runner} runner | ||
* @api public | ||
*/ | ||
function XUnit(runner) { | ||
Base.call(this, runner); | ||
var stats = this.stats | ||
, tests = [] | ||
, self = this; | ||
runner.on('test end', function(test){ | ||
tests.push(test); | ||
}); | ||
runner.on('end', function(){ | ||
console.log(tag('testsuite', { | ||
name: 'Mocha Tests' | ||
, tests: stats.tests | ||
, failures: stats.failures | ||
, skip: stats.tests - stats.failures - stats.passes | ||
, timestamp: (new Date).toUTCString() | ||
, time: stats.duration / 1000 | ||
}, false)); | ||
tests.forEach(test); | ||
console.log('</testsuite>'); | ||
}); | ||
} | ||
/** | ||
* Inherit from `Base.prototype`. | ||
*/ | ||
XUnit.prototype = new Base; | ||
XUnit.prototype.constructor = XUnit; | ||
/** | ||
* Output tag for the given `test.` | ||
*/ | ||
function test(test) { | ||
var attrs = { | ||
classname: test.fullTitle() | ||
, name: test.title | ||
, time: test.duration / 1000 | ||
}; | ||
if (test.failed) { | ||
var err = test.err; | ||
attrs.message = escape(err.message); | ||
console.log(tag('testcase', attrs, false, tag('failure', attrs, false, cdata(err.stack)))); | ||
} else if (test.pending) { | ||
console.log(tag('testcase', attrs, false, tag('skipped', {}, true))); | ||
} else { | ||
console.log(tag('testcase', attrs, true) ); | ||
} | ||
} | ||
/** | ||
* HTML tag helper. | ||
*/ | ||
function tag(name, attrs, close, content) { | ||
var end = close ? '/>' : '>' | ||
, pairs = [] | ||
, tag; | ||
for (var key in attrs) { | ||
pairs.push(key + '="' + escape(attrs[key]) + '"'); | ||
} | ||
tag = '<' + name + (pairs.length ? ' ' + pairs.join(' ') : '') + end; | ||
if (content) tag += content + '</' + name + end; | ||
return tag; | ||
} | ||
/** | ||
* Return cdata escaped CDATA `str`. | ||
*/ | ||
function cdata(str) { | ||
return '<![CDATA[' + escape(str) + ']]>'; | ||
} | ||
}); // module: reporters/xunit.js | ||
require.register("runnable.js", function(module, exports, require){ | ||
@@ -2011,2 +2136,3 @@ | ||
if (err instanceof Error) return done(err); | ||
if (null != err) return done(new Error('done() invoked with non-Error: ' + err)); | ||
done(); | ||
@@ -2129,3 +2255,3 @@ }); | ||
var leaks = utils.filter(utils.keys(global), function(key){ | ||
return !~utils.indexOf(this._globals, key); | ||
return !~utils.indexOf(this._globals, key) && (!global.navigator || 'onerror' !== key); | ||
}, this); | ||
@@ -2132,0 +2258,0 @@ |
0.8.0 / 2011-12-28 | ||
================== | ||
* Added `XUnit` reporter [FeeFighters/visionmedia] | ||
* Added `say(1)` notification support [Maciej Małecki] | ||
* Changed: fail when done() is invoked with a non-Error. Closes #171 | ||
* Fixed `err.stack`, defaulting to message. Closes #180 | ||
* Fixed: `make tm` mkdir -p the dest. Closes #137 | ||
* Fixed mocha(1) --help bin name | ||
* Fixed `-d` for `--debug` support | ||
0.7.1 / 2011-12-22 | ||
@@ -3,0 +14,0 @@ ================== |
@@ -12,3 +12,3 @@ | ||
exports.version = '0.7.1'; | ||
exports.version = '0.8.0'; | ||
@@ -15,0 +15,0 @@ exports.utils = require('./utils'); |
@@ -131,3 +131,3 @@ | ||
var err = test.err | ||
, stack = err.stack | ||
, stack = err.stack || err.message | ||
, message = err.message || '' | ||
@@ -134,0 +134,0 @@ , index = stack.indexOf(message) + message.length |
@@ -128,2 +128,6 @@ | ||
/** | ||
* Display error `msg`. | ||
*/ | ||
function error(msg) { | ||
@@ -130,0 +134,0 @@ $('<div id="error">' + msg + '</div>').appendTo('body'); |
@@ -13,1 +13,2 @@ | ||
exports.JSONStream = require('./json-stream'); | ||
exports.XUnit = require('./xunit') |
@@ -14,2 +14,9 @@ | ||
/** | ||
* Initialize a new `Teamcity` reporter. | ||
* | ||
* @param {Runner} runner | ||
* @api public | ||
*/ | ||
function Teamcity(runner) { | ||
@@ -24,15 +31,15 @@ Base.call(this, runner); | ||
runner.on('test', function(test) { | ||
console.log("##teamcity[testStarted name='%s']", test.fullTitle()); | ||
console.log("##teamcity[testStarted name='%s']", escape(test.fullTitle())); | ||
}); | ||
runner.on('fail', function(test, err) { | ||
console.log("##teamcity[testFailed name='%s' message='%s']", test.fullTitle(), err.message); | ||
console.log("##teamcity[testFailed name='%s' message='%s']", escape(test.fullTitle()), escape(err.message)); | ||
}); | ||
runner.on('pending', function(test) { | ||
console.log("##teamcity[testIgnored name='%s' message='pending']", test.fullTitle()); | ||
console.log("##teamcity[testIgnored name='%s' message='pending']", escape(test.fullTitle())); | ||
}); | ||
runner.on('test end', function(test) { | ||
console.log("##teamcity[testFinished name='%s' duration='%s']", test.fullTitle(), test.duration); | ||
console.log("##teamcity[testFinished name='%s' duration='%s']", escape(test.fullTitle()), test.duration); | ||
}); | ||
@@ -44,1 +51,9 @@ | ||
} | ||
/** | ||
* Escape the given `str`. | ||
*/ | ||
function escape(str) { | ||
return str.replace(/'/g, "|'"); | ||
} |
@@ -140,2 +140,3 @@ | ||
if (err instanceof Error) return done(err); | ||
if (null != err) return done(new Error('done() invoked with non-Error: ' + err)); | ||
done(); | ||
@@ -142,0 +143,0 @@ }); |
@@ -95,3 +95,3 @@ | ||
var leaks = utils.filter(utils.keys(global), function(key){ | ||
return !~utils.indexOf(this._globals, key); | ||
return !~utils.indexOf(this._globals, key) && (!global.navigator || 'onerror' !== key); | ||
}, this); | ||
@@ -98,0 +98,0 @@ |
140
mocha.js
@@ -691,3 +691,3 @@ ;(function(){ | ||
exports.version = '0.7.0'; | ||
exports.version = '0.8.0'; | ||
@@ -837,3 +837,3 @@ exports.utils = require('./utils'); | ||
var err = test.err | ||
, stack = err.stack | ||
, stack = err.stack || err.message | ||
, message = err.message || '' | ||
@@ -1219,2 +1219,6 @@ , index = stack.indexOf(message) + message.length | ||
/** | ||
* Display error `msg`. | ||
*/ | ||
function error(msg) { | ||
@@ -1259,2 +1263,3 @@ $('<div id="error">' + msg + '</div>').appendTo('body'); | ||
exports.JSONStream = require('./json-stream'); | ||
exports.XUnit = require('./xunit') | ||
@@ -1837,2 +1842,9 @@ }); // module: reporters/index.js | ||
/** | ||
* Initialize a new `Teamcity` reporter. | ||
* | ||
* @param {Runner} runner | ||
* @api public | ||
*/ | ||
function Teamcity(runner) { | ||
@@ -1847,15 +1859,15 @@ Base.call(this, runner); | ||
runner.on('test', function(test) { | ||
console.log("##teamcity[testStarted name='%s']", test.fullTitle()); | ||
console.log("##teamcity[testStarted name='%s']", escape(test.fullTitle())); | ||
}); | ||
runner.on('fail', function(test, err) { | ||
console.log("##teamcity[testFailed name='%s' message='%s']", test.fullTitle(), err.message); | ||
console.log("##teamcity[testFailed name='%s' message='%s']", escape(test.fullTitle()), escape(err.message)); | ||
}); | ||
runner.on('pending', function(test) { | ||
console.log("##teamcity[testIgnored name='%s' message='pending']", test.fullTitle()); | ||
console.log("##teamcity[testIgnored name='%s' message='pending']", escape(test.fullTitle())); | ||
}); | ||
runner.on('test end', function(test) { | ||
console.log("##teamcity[testFinished name='%s' duration='%s']", test.fullTitle(), test.duration); | ||
console.log("##teamcity[testFinished name='%s' duration='%s']", escape(test.fullTitle()), test.duration); | ||
}); | ||
@@ -1868,4 +1880,117 @@ | ||
/** | ||
* Escape the given `str`. | ||
*/ | ||
function escape(str) { | ||
return str.replace(/'/g, "|'"); | ||
} | ||
}); // module: reporters/teamcity.js | ||
require.register("reporters/xunit.js", function(module, exports, require){ | ||
/** | ||
* Module dependencies. | ||
*/ | ||
var Base = require('./base') | ||
, utils = require('../utils') | ||
, escape = utils.escape; | ||
/** | ||
* Expose `XUnit`. | ||
*/ | ||
exports = module.exports = XUnit; | ||
/** | ||
* Initialize a new `XUnit` reporter. | ||
* | ||
* @param {Runner} runner | ||
* @api public | ||
*/ | ||
function XUnit(runner) { | ||
Base.call(this, runner); | ||
var stats = this.stats | ||
, tests = [] | ||
, self = this; | ||
runner.on('test end', function(test){ | ||
tests.push(test); | ||
}); | ||
runner.on('end', function(){ | ||
console.log(tag('testsuite', { | ||
name: 'Mocha Tests' | ||
, tests: stats.tests | ||
, failures: stats.failures | ||
, skip: stats.tests - stats.failures - stats.passes | ||
, timestamp: (new Date).toUTCString() | ||
, time: stats.duration / 1000 | ||
}, false)); | ||
tests.forEach(test); | ||
console.log('</testsuite>'); | ||
}); | ||
} | ||
/** | ||
* Inherit from `Base.prototype`. | ||
*/ | ||
XUnit.prototype = new Base; | ||
XUnit.prototype.constructor = XUnit; | ||
/** | ||
* Output tag for the given `test.` | ||
*/ | ||
function test(test) { | ||
var attrs = { | ||
classname: test.fullTitle() | ||
, name: test.title | ||
, time: test.duration / 1000 | ||
}; | ||
if (test.failed) { | ||
var err = test.err; | ||
attrs.message = escape(err.message); | ||
console.log(tag('testcase', attrs, false, tag('failure', attrs, false, cdata(err.stack)))); | ||
} else if (test.pending) { | ||
console.log(tag('testcase', attrs, false, tag('skipped', {}, true))); | ||
} else { | ||
console.log(tag('testcase', attrs, true) ); | ||
} | ||
} | ||
/** | ||
* HTML tag helper. | ||
*/ | ||
function tag(name, attrs, close, content) { | ||
var end = close ? '/>' : '>' | ||
, pairs = [] | ||
, tag; | ||
for (var key in attrs) { | ||
pairs.push(key + '="' + escape(attrs[key]) + '"'); | ||
} | ||
tag = '<' + name + (pairs.length ? ' ' + pairs.join(' ') : '') + end; | ||
if (content) tag += content + '</' + name + end; | ||
return tag; | ||
} | ||
/** | ||
* Return cdata escaped CDATA `str`. | ||
*/ | ||
function cdata(str) { | ||
return '<![CDATA[' + escape(str) + ']]>'; | ||
} | ||
}); // module: reporters/xunit.js | ||
require.register("runnable.js", function(module, exports, require){ | ||
@@ -2013,2 +2138,3 @@ | ||
if (err instanceof Error) return done(err); | ||
if (null != err) return done(new Error('done() invoked with non-Error: ' + err)); | ||
done(); | ||
@@ -2131,3 +2257,3 @@ }); | ||
var leaks = utils.filter(utils.keys(global), function(key){ | ||
return !~utils.indexOf(this._globals, key); | ||
return !~utils.indexOf(this._globals, key) && (!global.navigator || 'onerror' !== key); | ||
}, this); | ||
@@ -2134,0 +2260,0 @@ |
{ | ||
"name": "mocha" | ||
, "version": "0.7.1" | ||
, "version": "0.8.0" | ||
, "description": "simple, flexible, fun test framework" | ||
@@ -17,2 +17,3 @@ , "keywords": ["test", "bdd", "tdd", "tap"] | ||
, "debug": "*" | ||
, "say": "0.5.x" | ||
} | ||
@@ -19,0 +20,0 @@ , "devDependencies": { |
@@ -94,10 +94,2 @@ | ||
describe('when the callback is invoked with a non-Error', function(){ | ||
it('should pass', function(done){ | ||
var thing = new EventEmitter; | ||
thing.on('foo', done); | ||
thing.emit('foo', 'bar'); | ||
}) | ||
}) | ||
describe('when the callback is invoked several times', function(){ | ||
@@ -104,0 +96,0 @@ describe('without an error', function(){ |
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
316167
88
8526
4
+ Addedsay@0.5.x
+ Addedcolors@0.5.1(transitive)
+ Addedsay@0.5.0(transitive)
+ Addedtranslate@3.0.1(transitive)