Skip to content

jest/valid-title Correctness

🛠️ An auto-fix is available for this rule for some violations.

What it does

Checks that the titles of Jest blocks are valid.

Titles must be:

  • not empty,
  • strings,
  • not prefixed with their block name,
  • have no leading or trailing spaces.

Why is this bad?

Titles that are not valid can be misleading and make it harder to understand the purpose of the test.

Example

Examples of incorrect code for this rule:

javascript
describe("", () => {});
describe("foo", () => {
  it("", () => {});
});
it("", () => {});
test("", () => {});
xdescribe("", () => {});
xit("", () => {});
xtest("", () => {});

Examples of correct code for this rule:

javascript
describe('foo', () => {});
it('bar', () => {});
test('baz', () => {});


## References
- [Rule Source](https://github.com/oxc-project/oxc/blob/25ddb3519289dfe2a51e53b9b0c355d8ad950bbc/crates/oxc_linter/src/rules/jest/valid_title.rs)

Released under the MIT License.