Skip to content

jest/no-test-prefixes Style

🛠️ An auto-fix is available for this rule.

What it does

Require using .only and .skip over f and x.

Why is this bad?

Jest allows you to choose how you want to define focused and skipped tests, with multiple permutations for each:

  • only & skip: it.only, test.only, describe.only, it.skip, test.skip, describe.skip.
  • 'f' & 'x': fit, fdescribe, xit, xtest, xdescribe.

This rule enforces usages from the only & skip list.

Example

javascript
fit("foo"); // invalid
fdescribe("foo"); // invalid
xit("foo"); // invalid
xtest("foo"); // invalid
xdescribe("foo"); // invalid

This rule is compatible with eslint-plugin-vitest, to use it, add the following configuration to your .eslintrc.json:

json
{
  "rules": {
    "vitest/no-test-prefixes": "error"
  }
}

References

Released under the MIT License.