☕️ Classic, reliable, trusted test framework for Node.js and the browser
mocha.reporter() accepts a constructor
John Firebaugh9a3382f4c087
diff --git a/lib/mocha.js b/lib/mocha.jsindex ef112d6e..62641feb 100644--- a/lib/mocha.js+++ b/lib/mocha.js@@ -82,16 +82,20 @@ Mocha.prototype.addFile = function(file){};/**- * Set reporter to `name`, defaults to "dot".+ * Set reporter to `reporter`, defaults to "dot".*- * @param {String} name+ * @param {String|Function} reporter name of a reporter or a reporter constructor* @api public*/-Mocha.prototype.reporter = function(name){- name = name || 'dot';- this._reporter = require('./reporters/' + name);- if (!this._reporter) throw new Error('invalid reporter "' + name + '"');+Mocha.prototype.reporter = function(reporter){+ if ('function' == typeof reporter) {+ this._reporter = reporter;+ } else {+ reporter = reporter || 'dot';+ this._reporter = require('./reporters/' + reporter);+ if (!this._reporter) throw new Error('invalid reporter "' + reporter + '"');+ }return this;};