diff --git a/lib/interfaces/common.js b/lib/interfaces/common.js index e7e84b2511..53c8d8c26c 100644 --- a/lib/interfaces/common.js +++ b/lib/interfaces/common.js @@ -93,6 +93,9 @@ module.exports = function(suites, context, mocha) { * @returns {Suite} */ only: function only(opts) { + if (mocha.options.forbidOnly) { + throw createUnsupportedError('`.only` forbidden'); + } opts.isOnly = true; return this.create(opts); }, @@ -126,11 +129,7 @@ module.exports = function(suites, context, mocha) { suite.file = opts.file; suites.unshift(suite); if (opts.isOnly) { - if (mocha.options.forbidOnly && shouldBeTested(suite)) { - throw createUnsupportedError('`.only` forbidden'); - } - - suite.parent.appendOnlySuite(suite); + suite.markOnly(); } if (suite.pending) { if (mocha.options.forbidPending && shouldBeTested(suite)) {