mocha
Advanced tools
Comparing version 1.0.3 to 1.1.0
1.1.0 / 2012-05-30 | ||
================== | ||
* Added: check each `mocha(1)` arg for directories to walk | ||
* Added `--recursive` [tricknotes] | ||
* Added `context` for BDD [hokaccha] | ||
* Added styling for new clickable titles | ||
* Added clickable suite titles to HTML reporter | ||
* Added warning when strings are thrown as errors | ||
* Changed: green arrows again in HTML reporter styling | ||
* Changed ul/li elements instead of divs for better copy-and-pasting [joliss] | ||
* Fixed issue #325 - add better grep support to js api | ||
* Fixed: save timer references to avoid Sinon interfering. | ||
1.0.3 / 2012-04-30 | ||
@@ -3,0 +17,0 @@ ================== |
@@ -19,3 +19,3 @@ | ||
* | ||
* @api public. | ||
* @api public | ||
*/ | ||
@@ -128,3 +128,3 @@ | ||
* | ||
* @api publci | ||
* @api public | ||
*/ | ||
@@ -131,0 +131,0 @@ |
@@ -74,3 +74,3 @@ | ||
context.describe = function(title, fn){ | ||
context.describe = context.context = function(title, fn){ | ||
var suite = Suite.create(suites[0], title); | ||
@@ -77,0 +77,0 @@ suites.unshift(suite); |
@@ -24,3 +24,3 @@ | ||
exports.version = '1.0.3'; | ||
exports.version = '1.1.0'; | ||
@@ -63,2 +63,3 @@ /** | ||
* - `ignoreLeaks` ignore global leaks | ||
* - `grep` string or regexp to filter tests with | ||
* | ||
@@ -73,2 +74,3 @@ * @param {Object} options | ||
this.options = options; | ||
this.grep(options.grep); | ||
this.suite = new exports.Suite('', new exports.Context); | ||
@@ -161,2 +163,17 @@ this.ui(options.ui); | ||
/** | ||
* Add regexp to grep for to the options object | ||
* | ||
* @param {RegExp} or {String} re | ||
* @return {Mocha} | ||
* @api public | ||
*/ | ||
Mocha.prototype.grep = function(re){ | ||
this.options.grep = 'string' == typeof re | ||
? new RegExp(re) | ||
: re; | ||
return this; | ||
}; | ||
/** | ||
* Run tests and invoke `fn()` when complete. | ||
@@ -180,2 +197,2 @@ * | ||
return runner.run(fn); | ||
}; | ||
}; |
@@ -10,2 +10,12 @@ | ||
/** | ||
* Save timer references to avoid Sinon interfering (see GH-237). | ||
*/ | ||
var Date = global.Date | ||
, setTimeout = global.setTimeout | ||
, setInterval = global.setInterval | ||
, clearTimeout = global.clearTimeout | ||
, clearInterval = global.clearInterval; | ||
/** | ||
* Check if both stdio streams are associated with a tty. | ||
@@ -12,0 +22,0 @@ */ |
@@ -12,2 +12,12 @@ | ||
/** | ||
* Save timer references to avoid Sinon interfering (see GH-237). | ||
*/ | ||
var Date = global.Date | ||
, setTimeout = global.setTimeout | ||
, setInterval = global.setInterval | ||
, clearTimeout = global.clearTimeout | ||
, clearInterval = global.clearInterval; | ||
/** | ||
* Expose `Doc`. | ||
@@ -49,3 +59,4 @@ */ | ||
, canvas = stat.getElementsByTagName('canvas')[0] | ||
, stack = [root] | ||
, report = fragment('<ul id="report"></ul>') | ||
, stack = [report] | ||
, progress | ||
@@ -62,2 +73,3 @@ , ctx | ||
root.appendChild(stat); | ||
root.appendChild(report); | ||
@@ -70,7 +82,8 @@ if (progress) progress.size(40); | ||
// suite | ||
var el = fragment('<div class="suite"><h1>%s</h1></div>', suite.title); | ||
var url = location.origin + location.pathname + '?grep=^' + utils.escapeRegexp(suite.fullTitle()); | ||
var el = fragment('<li class="suite"><h1><a href="%s">%s</a></h1></li>', url, suite.title); | ||
// container | ||
stack[0].appendChild(el); | ||
stack.unshift(document.createElement('div')); | ||
stack.unshift(document.createElement('ul')); | ||
el.appendChild(stack[0]); | ||
@@ -101,7 +114,7 @@ }); | ||
if ('passed' == test.state) { | ||
var el = fragment('<div class="test pass %e"><h2>%e<span class="duration">%ems</span></h2></div>', test.speed, test.title, test.duration); | ||
var el = fragment('<li class="test pass %e"><h2>%e<span class="duration">%ems</span></h2></li>', test.speed, test.title, test.duration); | ||
} else if (test.pending) { | ||
var el = fragment('<div class="test pass pending"><h2>%e</h2></div>', test.title); | ||
var el = fragment('<li class="test pass pending"><h2>%e</h2></li>', test.title); | ||
} else { | ||
var el = fragment('<div class="test fail"><h2>%e</h2></div>', test.title); | ||
var el = fragment('<li class="test fail"><h2>%e</h2></li>', test.title); | ||
var str = test.err.stack || test.err.toString(); | ||
@@ -108,0 +121,0 @@ |
@@ -30,19 +30,19 @@ | ||
runner.on('test', function(test) { | ||
console.log("##teamcity[testStarted name='%s']", escape(test.fullTitle())); | ||
console.log("##teamcity[testStarted name='" + escape(test.fullTitle()) + "']"); | ||
}); | ||
runner.on('fail', function(test, err) { | ||
console.log("##teamcity[testFailed name='%s' message='%s']", escape(test.fullTitle()), escape(err.message)); | ||
console.log("##teamcity[testFailed name='" + escape(test.fullTitle()) + "' message='" + escape(err.message) + "']"); | ||
}); | ||
runner.on('pending', function(test) { | ||
console.log("##teamcity[testIgnored name='%s' message='pending']", escape(test.fullTitle())); | ||
console.log("##teamcity[testIgnored name='" + escape(test.fullTitle()) + "' message='pending']"); | ||
}); | ||
runner.on('test end', function(test) { | ||
console.log("##teamcity[testFinished name='%s' duration='%s']", escape(test.fullTitle()), test.duration); | ||
console.log("##teamcity[testFinished name='" + escape(test.fullTitle()) + "' duration='" + test.duration + "']"); | ||
}); | ||
runner.on('end', function() { | ||
console.log("##teamcity[testSuiteFinished name='mocha.suite' duration='%s']", stats.duration); | ||
console.log("##teamcity[testSuiteFinished name='mocha.suite' duration='" + stats.duration + "']"); | ||
}); | ||
@@ -56,3 +56,12 @@ } | ||
function escape(str) { | ||
return str.replace(/'/g, "|'"); | ||
} | ||
return str | ||
.replace(/\|/g, "||") | ||
.replace(/\n/g, "|n") | ||
.replace(/\r/g, "|r") | ||
.replace(/\[/g, "|[") | ||
.replace(/\]/g, "|]") | ||
.replace(/\u0085/g, "|x") | ||
.replace(/\u2028/g, "|l") | ||
.replace(/\u2029/g, "|p") | ||
.replace(/'/g, "|'"); | ||
} |
@@ -11,2 +11,12 @@ | ||
/** | ||
* Save timer references to avoid Sinon interfering (see GH-237). | ||
*/ | ||
var Date = global.Date | ||
, setTimeout = global.setTimeout | ||
, setInterval = global.setInterval | ||
, clearTimeout = global.clearTimeout | ||
, clearInterval = global.clearInterval; | ||
/** | ||
* Expose `XUnit`. | ||
@@ -13,0 +23,0 @@ */ |
@@ -10,2 +10,12 @@ | ||
/** | ||
* Save timer references to avoid Sinon interfering (see GH-237). | ||
*/ | ||
var Date = global.Date | ||
, setTimeout = global.setTimeout | ||
, setInterval = global.setInterval | ||
, clearTimeout = global.clearTimeout | ||
, clearInterval = global.clearInterval; | ||
/** | ||
* Expose `Runnable`. | ||
@@ -12,0 +22,0 @@ */ |
@@ -141,2 +141,5 @@ | ||
test.state = 'failed'; | ||
if ('string' == typeof err) { | ||
err = new Error('the string "' + err + '" was thrown, throw an Error :)'); | ||
} | ||
this.emit('fail', test, err); | ||
@@ -143,0 +146,0 @@ }; |
@@ -182,2 +182,3 @@ | ||
* @return {String} | ||
* @api private | ||
*/ | ||
@@ -190,2 +191,14 @@ | ||
.replace(/[^-\w]/g, ''); | ||
}; | ||
/** | ||
* Escape regular expression characters in `str`. | ||
* | ||
* @param {String} str | ||
* @return {String} | ||
* @api private | ||
*/ | ||
exports.escapeRegexp = function(str){ | ||
return str.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&"); | ||
}; |
{ | ||
"name": "mocha" | ||
, "version": "1.0.3" | ||
, "version": "1.1.0" | ||
, "description": "simple, flexible, fun test framework" | ||
@@ -5,0 +5,0 @@ , "keywords": ["test", "bdd", "tdd", "tap"] |
Sorry, the diff of this file is too big to display
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 too big to display
289231
9966
64