Skip to content

noctcore-code-quality/no-focused-tests

Ban .only / fdescribe / fit so a focused test never silently lands in CI.

Recommended preset: error · Autofix: no · Suggestions: no · Type information: not needed

A focused test (it.only, fdescribe, …) silences the rest of the suite. Committed by accident it turns a green CI run into a lie — the suite “passes” because almost none of it ran. This rule makes a focused test a lint error so it can’t merge.

  • .only resolved back to a it / describe / test runner, including chained modifiers (test.concurrent.only, describe.concurrent.only).
  • The Jest/Jasmine focused-call forms fdescribe(...), fit(...), ddescribe(...) — but only as a bare-identifier callee, so an unrelated obj.fit(...) method is not flagged.
Incorrect · src/example.test.ts · 3 reports
it.only('runs', () => {});
test.concurrent.only('case', () => {});
fdescribe('suite', () => {});
Correct · src/example.test.ts
it('runs', () => {});
layout.fit('contain'); // not a test runner
  • .only on something that is not a test runner (queue.only(...), db.batch.only(...)), and a plain variable named only.
  • A method named fit on some object (layout.fit('contain')): only the bare global counts.
  • Skipped tests (it.skip, xit): see skipped-tests-need-tracking.

You almost always want this on. Disable only in throwaway scratch suites.