Skip to content

armgit / mocha

Public Imported from GitHub
0

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

debug() instrumentation for runner

Tj Holowaychuk323e445ea81a
diff --git a/lib/runner.js b/lib/runner.js
index 9f7db06a..ee6c8928 100644
--- a/lib/runner.js
+++ b/lib/runner.js
@@ -4,6 +4,7 @@
*/
var EventEmitter = require('events').EventEmitter
+ , debug = require('debug')('runner')
, Test = require('./test')
, noop = function(){};
@@ -59,6 +60,7 @@ Runner.prototype.__proto__ = EventEmitter.prototype;
*/
Runner.prototype.grep = function(re){
+ debug('grep %s', re);
this._grep = re;
return this;
};
@@ -72,6 +74,7 @@ Runner.prototype.grep = function(re){
*/
Runner.prototype.globals = function(arr){
+ debug('globals %j', arr);
arr.forEach(function(arr){
this._globals.push(arr);
}, this);
@@ -334,6 +337,7 @@ Runner.prototype.runSuite = function(suite, fn){
var self = this
, i = 0;
+ debug('run suite %s', suite.fullTitle());
this.emit('suite', this.suite = suite);
function next() {
@@ -367,8 +371,11 @@ Runner.prototype.run = function(fn){
var self = this
, fn = fn || function(){};
+ debug('start');
+
// callback
self.on('end', function(){
+ debug('end');
process.removeListener('uncaughtException', uncaught);
fn(self.failures);
});
@@ -376,11 +383,13 @@ Runner.prototype.run = function(fn){
// run suites
this.emit('start');
this.runSuite(this.suite, function(){
+ debug('finished running');
self.emit('end');
});
// uncaught exception
function uncaught(err){
+ debug('uncaught exception');
self.fail(self.currentRunnable, err);
self.emit('test end', self.test);
self.emit('end');