jest/no-focused-tests
Disallow test.only, describe.only, fit and fdescribe
has suggestions
.only makes Jest run that test and skip every other one in the file. It's useful while debugging. If you commit one by accident, it hides failures in the tests that no longer run.
The f prefix does the same thing, so fit and fdescribe are reported too.
Configure#
Off by default. To turn it on:
bunfig.toml
[lint.rules]
"jest/no-focused-tests" = "error" # or "warn"Examples#
example.ts2 problems
import { expect, fit, test } from "@jest/globals";
test.onlyUnexpected focused test.("adds", () => {
expect(1 + 1).toBe(2);
});
fitUnexpected focused test.("subtracts", () => {
expect(2 - 1).toBe(1);
});example.tsNo problems
import { expect, it, test } from "@jest/globals";
test("adds", () => {
expect(1 + 1).toBe(2);
});
it("subtracts", () => {
expect(2 - 1).toBe(1);
});