noFocusedTests
Summary
Section titled “Summary”- Rule available since:
v1.6.0
- Diagnostic Category:
lint/suspicious/noFocusedTests
- This rule has an unsafe fix.
- The default severity of this rule is warning.
- This rule belongs to the following domains:
- Sources:
- Inspired from
jest/no-focused-tests
- Inspired from
vitest/no-focused-tests
- Inspired from
Description
Section titled “Description”Disallow focused tests.
Disabled test are useful when developing and debugging, because it forces the test suite to run only certain tests.
However, in pull/merge request, you usually want to run all the test suite.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”describe.only("foo", () => {});
code-block.js:1:10 lint/suspicious/noFocusedTests FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Don’t focus the test.
> 1 │ describe.only(“foo”, () => {});
│ ^^^^
2 │
ℹ The ‘only’ method is often used for debugging or during implementation. It should be removed before deploying to production.
ℹ Consider removing ‘only’ to ensure all tests are executed.
ℹ Unsafe fix: Remove focus from test.
1 │ describe.only(“foo”,·()·=>·{});
│ -----
test.only("foo", () => {});
code-block.js:1:6 lint/suspicious/noFocusedTests FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Don’t focus the test.
> 1 │ test.only(“foo”, () => {});
│ ^^^^
2 │
ℹ The ‘only’ method is often used for debugging or during implementation. It should be removed before deploying to production.
ℹ Consider removing ‘only’ to ensure all tests are executed.
ℹ Unsafe fix: Remove focus from test.
1 │ test.only(“foo”,·()·=>·{});
│ -----
test.only.each([["a"]])("%s", (a) => {});
code-block.js:1:6 lint/suspicious/noFocusedTests FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Don’t focus the test.
> 1 │ test.only.each([[“a”]])(“%s”, (a) => {});
│ ^^^^
2 │
ℹ The ‘only’ method is often used for debugging or during implementation. It should be removed before deploying to production.
ℹ Consider removing ‘only’ to ensure all tests are executed.
ℹ Unsafe fix: Remove focus from test.
1 │ test.only.each([[“a”]])(“%s”,·(a)·=>·{});
│ -----
test("foo", () => {});
test.each([["a"]])("%s", (a) => {});
How to configure
Section titled “How to configure”{ "linter": { "rules": { "suspicious": { "noFocusedTests": "error" } } }}