diff --git a/lib/mocha.js b/lib/mocha.js index 9b3b9e5464..33f359c3b4 100644 --- a/lib/mocha.js +++ b/lib/mocha.js @@ -102,7 +102,9 @@ function Mocha(options) { // files which were in require.cache // by the moment of mocha instance creation - this._requireCache = this._getRequireCache(); + this._requireCache = process.browser + ? [] + : this._getRequireCache(); } /** @@ -225,7 +227,10 @@ Mocha.prototype.loadFiles = function(fn) { suite.emit('post-require', global, file, self); }); - this._flushRequireCache(); + if (!process.browser) { + this._flushRequireCache(); + } + fn && fn(); }; @@ -258,7 +263,7 @@ Mocha.prototype._growl = function(runner, reporter) { * @api private */ Mocha.prototype._getRequireCache = function() { - return Object.keys(require.cache || {}); + return Object.keys(require.cache); }; /**