Skip to content

Commit

Permalink
throw exception if --forbid-only option is set even if suite is not s…
Browse files Browse the repository at this point in the history
…elected by grep
  • Loading branch information
arvidOtt committed May 5, 2020
1 parent c2c8dc8 commit f871782
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/interfaces/common.js
Expand Up @@ -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);
},
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit f871782

Please sign in to comment.