💼 This rule is enabled in the ✅ recommended
config.
🔧 This rule is automatically fixable by the --fix
CLI option.
Duplicate test cases can cause confusion, can be hard to detect manually in a long file, and serve no purpose.
As of ESLint v9, ESLint attempts to detect and disallow duplicate tests.
This rule detects duplicate test cases.
Examples of incorrect code for this rule:
/* eslint eslint-plugin/no-identical-tests: error */
new RuleTester().run('foo', bar, {
valid: [
'foo',
'foo', // duplicate of previous
],
invalid: [
{
code: 'bar',
errors: [{ messageId: 'my-message', type: 'CallExpression' }],
},
{
code: 'bar',
errors: [{ messageId: 'my-message', type: 'CallExpression' }],
}, // duplicate of previous
],
});
Examples of correct code for this rule:
/* eslint eslint-plugin/no-identical-tests: error */
new RuleTester().run('foo', bar, {
valid: ['foo', 'bar'],
invalid: [
{
code: 'baz',
errors: [{ messageId: 'my-message', type: 'CallExpression' }],
},
],
});