useLowercaseTestTitle (JavaScript)
Summary
Section titled “Summary”- Rule available since:
v2.6.0 - Diagnostic Category:
lint/nursery/useLowercaseTestTitle - This rule has an unsafe fix.
- The default severity of this rule is information.
- This rule belongs to the following domains:
- Sources:
- Same as
jest/prefer-lowercase-title - Same as
vitest/prefer-lowercase-title - Same as
playwright/prefer-lowercase-title
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "useLowercaseTestTitle": "error" } } }}Description
Section titled “Description”Require test and test suite titles to start with a lowercase letter.
Titles of describe, test, it, and bench blocks often read as a sentence,
such as it("returns the cached value").
Starting every title with a lowercase letter keeps test reports consistent.
Only the first character of the title is checked, so names and acronyms later in the title can keep their capitalization.
Titles built from a template literal with ${} placeholders are not checked.
The fix is unsafe because test runners use titles to name stored snapshots and to select which tests to run. Renaming a test can leave its stored snapshot orphaned.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”it("Returns the cached value", () => {});code-block.js:1:4 lint/nursery/useLowercaseTestTitle FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ This test title starts with an uppercase letter.
> 1 │ it("Returns the cached value", () => {});
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ Test titles that consistently start with a lowercase letter make test reports easier to read.
ℹ Change the first letter of the title to lowercase.
ℹ 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.
ℹ Unsafe fix: Lowercase the first letter of the title.
1 │ - it("Returns·the·cached·value",·()·=>·{});
1 │ + it("returns·the·cached·value",·()·=>·{});
2 2 │
describe(`Cache`, () => {});code-block.js:1:10 lint/nursery/useLowercaseTestTitle FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ This test title starts with an uppercase letter.
> 1 │ describe(`Cache`, () => {});
│ ^^^^^^^
2 │
ℹ Test titles that consistently start with a lowercase letter make test reports easier to read.
ℹ Change the first letter of the title to lowercase.
ℹ 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.
ℹ Unsafe fix: Lowercase the first letter of the title.
1 │ - describe(`Cache`,·()·=>·{});
1 │ + describe(`cache`,·()·=>·{});
2 2 │
it("returns the cached value", () => {});describe("cache", () => {});test("parses JSON input", () => {});test("123 is a number", () => {});Options
Section titled “Options”allowedPrefixes
Section titled “allowedPrefixes”Type: string[]
Default: []
A list of prefixes. Titles that start with one of these prefixes are not checked.
Uppercase and lowercase letters are treated as different, so the prefix GET doesn’t match a title that starts with Get.
{ "linter": { "rules": { "nursery": { "useLowercaseTestTitle": { "level": "on", "options": { "allowedPrefixes": [ "GET", "POST" ] } } } } }}Invalid
Section titled “Invalid”test("Returns the list of users", () => {});code-block.js:1:6 lint/nursery/useLowercaseTestTitle FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ This test title starts with an uppercase letter.
> 1 │ test("Returns the list of users", () => {});
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ Test titles that consistently start with a lowercase letter make test reports easier to read.
ℹ Change the first letter of the title to lowercase.
ℹ 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.
ℹ Unsafe fix: Lowercase the first letter of the title.
1 │ - test("Returns·the·list·of·users",·()·=>·{});
1 │ + test("returns·the·list·of·users",·()·=>·{});
2 2 │
test("GET /users returns the list of users", () => {});describe("POST /users", () => {});Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.