oxc-project/oxc · warning · OxcDiagnostic

Some tests appear to be inside comments.

Error message

Some tests appear to be inside comments.

What it means

Diagnostic from the oxlint rule `jest/no-commented-out-tests` (shared with vitest) in crates/oxc_linter/src/rules/shared/jest_vitest/no_commented_out_tests.rs:8. The rule scans comments (byte-level via memchr) for test-like content such as `it(`, `test(`, or `describe(` and reports the comment span. Commented-out tests rot silently and are easily forgotten, so the linter asks you to delete or restore them.

Source

Thrown at crates/oxc_linter/src/rules/shared/jest_vitest/no_commented_out_tests.rs:8

use memchr::memchr3_iter;
use oxc_diagnostics::OxcDiagnostic;
use oxc_span::Span;

use crate::context::LintContext;

fn no_commented_out_tests_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Some tests appear to be inside comments.")
        .with_help("Remove or uncomment this test.")
        .with_label(span)
}

pub const DOCUMENTATION: &str = r"### What it does

This rule raises a warning about commented-out tests. It's similar to the
`no-disabled-tests` rule.

### Why is this bad?

You may forget to uncomment some tests. This rule raises a warning about commented-out tests.

It is generally better to skip a test if it's flaky, or remove it if it's no longer needed.

### Examples

Examples of **incorrect** code for this rule:

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Uncomment the test and make it pass, or delete it entirely (git history preserves it)
  2. If the test must stay disabled temporarily, convert it to test.todo('...') which is explicit and tracked
  3. If the flagged comment is prose (e.g. a review note quoting a test), reword it so it does not start with a bare it(/test(/describe( call pattern

Example fix

// before
// it('adds numbers', () => {
//   expect(add(1, 2)).toBe(3);
// });

// after
it('adds numbers', () => {
  expect(add(1, 2)).toBe(3);
});
// or, if not ready: test.todo('adds numbers');
Defensive patterns

Strategy: validation

Validate before calling

rg -n "//.*(\bit\(|\btest\(|\bdescribe\()" tests/

Prevention

When it happens

Trigger: A line or block comment whose text contains a call that looks like a test: `// it('works', () => {...})`, `// test('foo')`, `/* describe('suite', ...) */`. The diagnostic is raised on the comment span itself, not on any parsed AST node.

Common situations: Temporarily disabling a failing test before a deadline; committing WIP with commented tests; refactors where old tests were commented rather than deleted; code review comments quoting test code above a real test.

Related errors


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/b136258060541e95. Report an issue: GitHub.