diff --git a/docs/rules/no-exclusive-tests.md b/docs/rules/no-exclusive-tests.md index 4cf658d..07c1319 100644 --- a/docs/rules/no-exclusive-tests.md +++ b/docs/rules/no-exclusive-tests.md @@ -8,7 +8,7 @@ This rule reminds you to remove `.only` from your tests by raising a warning whe ## Rule Details -This rule looks for every `describe.only`, `it.only`, `suite.only` and `test.only` occurrences within the source code. +This rule looks for every `describe.only`, `it.only`, `suite.only`, `test.only` and `context.only` occurrences within the source code. Of course there are some edge-cases which can’t be detected by this rule e.g.: ```js diff --git a/lib/rules/no-exclusive-tests.js b/lib/rules/no-exclusive-tests.js index 4b8e7d5..f0e6249 100644 --- a/lib/rules/no-exclusive-tests.js +++ b/lib/rules/no-exclusive-tests.js @@ -5,7 +5,8 @@ module.exports = function (context) { 'it', 'describe', 'suite', - 'test' + 'test', + 'context' ]; function matchesMochaTestFunction(object) { diff --git a/test/rules/no-exclusive-tests.js b/test/rules/no-exclusive-tests.js index 3afd4af..8bfb937 100644 --- a/test/rules/no-exclusive-tests.js +++ b/test/rules/no-exclusive-tests.js @@ -16,6 +16,8 @@ eslintTester.addRuleTest('lib/rules/no-exclusive-tests', { 'test()', 'suite.skip()', 'test.skip()', + 'context()', + 'context.skip()', 'var appliedOnly = describe.only; appliedOnly.apply(describe)', 'var calledOnly = it.only; calledOnly.call(it)', 'var dynamicOnly = "only"; suite[dynamicOnly]()' @@ -53,6 +55,14 @@ eslintTester.addRuleTest('lib/rules/no-exclusive-tests', { { code: 'test["only"]()', errors: [ { message: expectedErrorMessage, column: 5, line: 1 } ] + }, + { + code: 'context.only()', + errors: [ { message: expectedErrorMessage, column: 8, line: 1 } ] + }, + { + code: 'context["only"]()', + errors: [ { message: expectedErrorMessage, column: 8, line: 1 } ] } ]