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/36ebb3e7841818c238c44349d6cf859db4177d55/crates/oxc_linter/src/rules/jest/valid_title.rs)

Released under the MIT License.