diff --git a/lib/interfaces/common.js b/lib/interfaces/common.js index 01f1a8936d..6505e05a76 100644 --- a/lib/interfaces/common.js +++ b/lib/interfaces/common.js @@ -74,7 +74,6 @@ module.exports = function (suites, context, mocha) { * @returns {Suite} */ only: function only (opts) { - mocha.options.hasOnly = true; opts.isOnly = true; return this.create(opts); }, @@ -108,7 +107,6 @@ module.exports = function (suites, context, mocha) { suites.unshift(suite); if (opts.isOnly) { suite.parent._onlySuites = suite.parent._onlySuites.concat(suite); - mocha.options.hasOnly = true; } if (typeof opts.fn === 'function') { opts.fn.call(suite); @@ -132,7 +130,6 @@ module.exports = function (suites, context, mocha) { */ only: function (mocha, test) { test.parent._onlyTests = test.parent._onlyTests.concat(test); - mocha.options.hasOnly = true; return test; }, diff --git a/lib/mocha.js b/lib/mocha.js index bfc0238d46..7c77d6f90d 100644 --- a/lib/mocha.js +++ b/lib/mocha.js @@ -519,7 +519,6 @@ Mocha.prototype.run = function (fn) { var reporter = new this._reporter(runner, options); runner.ignoreLeaks = options.ignoreLeaks !== false; runner.fullStackTrace = options.fullStackTrace; - runner.hasOnly = options.hasOnly; runner.asyncOnly = options.asyncOnly; runner.allowUncaught = options.allowUncaught; runner.forbidOnly = options.forbidOnly; diff --git a/lib/runner.js b/lib/runner.js index b6e6e1f24a..0eeb4b0bd3 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -820,7 +820,7 @@ Runner.prototype.run = function (fn) { // callback this.on('end', function () { - if (self.forbidOnly && self.hasOnly) { + if (self.forbidOnly && hasOnly(rootSuite)) { self.failures += self.stats.tests; } if (self.forbidPending) {