jest/no-commented-out-tests

Disallow tests that are inside a comment

A test inside a comment never runs, and the test output doesn't tell you. It's easy to comment one out while debugging and forget about it.

To turn a test off for now, use test.skip or test.todo, which show up in the summary. If nobody needs the test, delete it.

A comment is reported if one of its lines starts with a call to test, it or describe. That includes xtest, fit, test.only and the like.

Configure#

Off by default. To turn it on:

bunfig.toml
[lint.rules]
"jest/no-commented-out-tests" = "error" # or "warn"

Examples#

example.ts1 problem
import { expect, test } from "@jest/globals";

// test("rounds down", () => {
//   expect(Math.floor(1.9)).toBe(1);
// });
example.ts1 problem
import { describe, expect, it } from "@jest/globals";

describe("Math.floor", () => {
  /*
  it.only("rounds down", () => {
    expect(Math.floor(1.9)).toBe(1);
  });
  */
});
example.tsNo problems
import { expect, test } from "@jest/globals";

test.skip("rounds down", () => {
  expect(Math.floor(1.9)).toBe(1);
});

// test negative numbers too
test.todo("rounds negative numbers down");