noIdenticalTestTitle (JavaScript)
Language JavaScript (and super languages)
Summary
Section titled “Summary”- Rule available since:
v2.4.12 - Diagnostic Category:
lint/suspicious/noIdenticalTestTitle - This rule is recommended, meaning it is enabled by default.
- This rule doesn’t have a fix.
- The default severity of this rule is warning.
- This rule belongs to the following domains:
- Sources:
- Same as
jest/no-identical-title - Same as
vitest/no-identical-title - Same as
playwright/no-identical-title
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "suspicious": { "noIdenticalTestTitle": "error" } } }}Description
Section titled “Description”Disallow identical titles in test suites and test cases.
Having identical titles for two different tests or test suites at the same level may create confusion. For example, when a test fails it is hard to tell which test exactly failed based on its title alone.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”it('should do bar', () => {});it('should do bar', () => {});code-block.js:1:4 lint/suspicious/noIdenticalTestTitle ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ The test title "should do bar" is used more than once in the same scope.
> 1 │ it('should do bar', () => {});
│ ^^^^^^^^^^^^^^^
2 │ it('should do bar', () => {});
3 │
ℹ The test title "should do bar" is repeated here.
1 │ it('should do bar', () => {});
> 2 │ it('should do bar', () => {});
│ ^^^^^^^^^^^^^^^
3 │
ℹ Rename the duplicated test calls to give each a unique, descriptive title.
describe('foo', () => { it('should do bar', () => {}); it('should do bar', () => {});});code-block.js:2:6 lint/suspicious/noIdenticalTestTitle ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ The test title "should do bar" is used more than once in the same scope.
1 │ describe('foo', () => {
> 2 │ it('should do bar', () => {});
│ ^^^^^^^^^^^^^^^
3 │ it('should do bar', () => {});
4 │ });
ℹ The test title "should do bar" is repeated here.
1 │ describe('foo', () => {
2 │ it('should do bar', () => {});
> 3 │ it('should do bar', () => {});
│ ^^^^^^^^^^^^^^^
4 │ });
5 │
ℹ Rename the duplicated test calls to give each a unique, descriptive title.
describe('foo', () => {});describe('foo', () => {});code-block.js:1:10 lint/suspicious/noIdenticalTestTitle ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ The describe title "foo" is used more than once in the same scope.
> 1 │ describe('foo', () => {});
│ ^^^^^
2 │ describe('foo', () => {});
3 │
ℹ The describe title "foo" is repeated here.
1 │ describe('foo', () => {});
> 2 │ describe('foo', () => {});
│ ^^^^^
3 │
ℹ Rename the duplicated describe calls to give each a unique, descriptive title.
describe('foo', () => { describe('baz', () => {}); describe('baz', () => {});});code-block.js:2:12 lint/suspicious/noIdenticalTestTitle ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ The describe title "baz" is used more than once in the same scope.
1 │ describe('foo', () => {
> 2 │ describe('baz', () => {});
│ ^^^^^
3 │ describe('baz', () => {});
4 │ });
ℹ The describe title "baz" is repeated here.
1 │ describe('foo', () => {
2 │ describe('baz', () => {});
> 3 │ describe('baz', () => {});
│ ^^^^^
4 │ });
5 │
ℹ Rename the duplicated describe calls to give each a unique, descriptive title.
describe('foo', () => { it('should do foo', () => {}); it('should do bar', () => {});});
describe('bar', () => {});describe('foo', () => { describe('baz', () => { it('should work', () => {}); }); describe('bar', () => { it('should work', () => {}); });});Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.