Skip to content

Commit

Permalink
make forbidOnly option throw exception even if suite is excluded by grep
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidOtt authored and boneskull committed Jun 2, 2020
1 parent 4b976f5 commit a223e2c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/interfaces/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ module.exports = function(suites, context, mocha) {
* @returns {Suite}
*/
only: function only(opts) {
if (mocha.options.forbidOnly) {
throw createForbiddenExclusivityError(mocha);
}
opts.isOnly = true;
return this.create(opts);
},
Expand Down Expand Up @@ -130,12 +133,14 @@ module.exports = function(suites, context, mocha) {
if (mocha.options.forbidOnly && shouldBeTested(suite)) {
throw createForbiddenExclusivityError(mocha);
}
suite.parent.appendOnlySuite(suite);
suite.markOnly();
}
if (suite.pending) {
if (mocha.options.forbidPending && shouldBeTested(suite)) {
throw createUnsupportedError('Pending test forbidden');
}
if (
suite.pending &&
mocha.options.forbidPending &&
shouldBeTested(suite)
) {
throw createUnsupportedError('Pending test forbidden');
}
if (typeof opts.fn === 'function') {
opts.fn.call(suite);
Expand Down

0 comments on commit a223e2c

Please sign in to comment.