oxc-project/oxc · warning · OxcDiagnostic
Unexpected focused test.
Error message
Unexpected focused test.
What it means
Diagnostic from oxlint rule `jest/no-focused-tests` (shared with vitest) in crates/oxc_linter/src/rules/shared/jest_vitest/no_focused_tests.rs:14. Jest/Vitest exclusivity (`.only`, plus `fit`/`fdescribe` prefix forms) makes the runner execute only the focused tests, so a stray `.only` silently skips the entire rest of the suite. The rule reminds you to remove focus before committing.
Source
Thrown at crates/oxc_linter/src/rules/shared/jest_vitest/no_focused_tests.rs:14
use oxc_ast::AstKind;
use oxc_diagnostics::OxcDiagnostic;
use oxc_span::Span;
use crate::{
context::LintContext,
utils::{
JestFnKind, JestGeneralFnKind, MemberExpressionElement, ParsedGeneralJestFnCall,
PossibleJestNode, parse_general_jest_fn_call,
},
};
fn no_focused_tests_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Unexpected focused test.")
.with_help("Remove focus from test.")
.with_label(span)
}
pub const DOCUMENTATION: &str = r"### 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.
### ExamplesView on GitHub (pinned to e1e7af627c)
Solutions
- Remove `.only` / replace `fit` with `it` before committing
- Add a CI guard: rg -n '\.(only)\(|\bfit\(|\bfdescribe\(' in tests fails the build (or use --forbid-only in vitest/jest CLI)
- Run the full suite once locally before pushing instead of only the focused subset
Example fix
// before
it.only('checks total', fn);
fit('checks tax', fn);
// after
it('checks total', fn);
it('checks tax', fn); Defensive patterns
Strategy: validation
Validate before calling
rg -n "\.(only)\(|\bfit\(|\bfdescribe\(" tests/ && exit 1 || exit 0 # fail on focused tests Prevention
- Also pass --forbid-only to jest/vitest CLI runs as a second net
- Run the full suite locally before pushing; focused-only runs hide it
- Add the grep above as a CI step so .only can never reach main
When it happens
Trigger: A member chain on a test/describe call containing `only` (test.only, it.only, describe.only) or names starting with `f` (fit, fdescribe), detected via parse_general_jest_fn_call over member expression elements. The diagnostic spans the callee and the help says 'Remove focus from test.'
Common situations: Debugging one test locally with .only and committing it; entire CI runs green while only one test executed; fit left from pairing sessions; merges that carry focused tests into main.
Related errors
- Matchers must be called to assert.
- Expect has an unknown modifier.
- Async assertions must be awaited.
- Promises which return async assertions must be awaited.
- Expect takes at most {} argument{}
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/370f8f37e831c73a.
Report an issue: GitHub.