useValidTestTitle (JavaScript)
Language JavaScript (and super languages)
Summary
Section titled “Summary”- Diagnostic Category:
lint/nursery/useValidTestTitle - This rule has a safe fix.
- The default severity of this rule is warning.
- This rule belongs to the following domains:
- Sources:
- Same as
jest/valid-title - Same as
vitest/valid-title
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "useValidTestTitle": "error" } } }}Description
Section titled “Description”Enforce valid titles for unit test cases and test suites.
Checks that the titles of test blocks (describe, test, it) are valid:
- Titles must not be empty.
- Titles must not have accidental leading or trailing whitespace.
- Titles must be string or template literals.
- Titles must not contain disallowed words (if configured).
Examples
Section titled “Examples”Invalid
Section titled “Invalid”it("", () => {});code-block.js:1:4 lint/nursery/useValidTestTitle ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ The test title is empty.
> 1 │ it("", () => {});
│ ^^
2 │
ℹ A title is required to identify the test in test reports.
ℹ Provide a descriptive title for this test.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
describe(" foo", () => {});code-block.js:1:10 lint/nursery/useValidTestTitle FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ The describe title has leading or trailing whitespace.
> 1 │ describe(" foo", () => {});
│ ^^^^^^
2 │
ℹ Accidental whitespace can cause inconsistent test output and formatting issues in reports.
ℹ Remove the accidental whitespace at the start of the title.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
ℹ Safe fix: Trim leading and trailing whitespace from the title.
1 │ describe("·foo",·()·=>·{});
│ -
test(123, () => {});code-block.js:1:6 lint/nursery/useValidTestTitle ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ The test title is not a string.
> 1 │ test(123, () => {});
│ ^^^
2 │
ℹ Test titles must be strings to ensure test runners and reporters can properly display them.
ℹ Provide a string literal or template literal as the title.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
it("should work", () => {});describe("my suite", () => {});Options
Section titled “Options”disallowedWords
Section titled “disallowedWords”A list of words that are not allowed in test titles. Matching is whole-word and case-insensitive.
Default: []
{ "linter": { "rules": { "nursery": { "useValidTestTitle": { "level": "on", "options": { "disallowedWords": [ "skip", "only" ] } } } } }}Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.