jest/no-focused-tests Correctness β
What it does β
This rule reminds you to remove .only
from your tests by raising a warning whenever you are using the exclusivity feature.
Why is this bad? β
Jest has a feature that allows you to focus tests by appending .only
or prepending f
to a test-suite or a test-case. This feature is really helpful to debug a failing test, so you donβt have to execute all of your tests. After you have fixed your test and before committing the changes you have to remove .only
to ensure all tests are executed on your build system.
Example β
javascript
describe.only("foo", () => {});
it.only("foo", () => {});
describe["only"]("bar", () => {});
it["only"]("bar", () => {});
test.only("foo", () => {});
test["only"]("bar", () => {});
fdescribe("foo", () => {});
fit("foo", () => {});
fit.each`
table
`();
This rule is compatible with eslint-plugin-vitest, to use it, add the following configuration to your .eslintrc.json
:
json
{
"rules": {
"vitest/no-focused-tests": "error"
}
}