Linter · Rules
jest/no-test-prefixes
Require .only and .skip instead of the f and x prefixes
fit and fdescribe are short names for it.only and describe.only. xit, xtest and xdescribe are short names for it.skip, test.skip and describe.skip. One extra letter is easy to miss in a review, and a search for .only or .skip doesn't find it.
--fix rewrites the short name to the long one. It doesn't change your imports.
Configure
Off by default. To turn it on:
bunfig.toml
[lint.rules]
"jest/no-test-prefixes" = "error" # or "warn"
Examples
Reported:
import { expect, fit, xdescribe, xtest } from "@jest/globals";
fit("adds", () => {
expect(1 + 1).toBe(2);
});
xtest("subtracts", () => {
expect(3 - 1).toBe(2);
});
xdescribe("division", () => {});
Not reported:
import { describe, expect, it, test } from "@jest/globals";
it.only("adds", () => {
expect(1 + 1).toBe(2);
});
test.skip("subtracts", () => {
expect(3 - 1).toBe(2);
});
describe.skip("division", () => {});
xit.each is reported too, and --fix turns it into it.skip.each:
import { expect, xit } from "@jest/globals";
xit.each([1, 2, 3])("%i is positive", n => {
expect(n).toBeGreaterThan(0);
});