Skip to content

noIdenticalTestTitle (JavaScript)

Language JavaScript (and super languages)
biome.json
{
"linter": {
"rules": {
"suspicious": {
"noIdenticalTestTitle": "error"
}
}
}
}

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.

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', () => {});
});
});