Skip to content

Commit 9e619a8

Browse files
committed
docs: modernize rule doc for no-identical-tests
1 parent 951d208 commit 9e619a8

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

docs/rules/no-identical-tests.md

+14-8
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,28 @@
44

55
⚒️ The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#--fix) can automatically fix some of the problems reported by this rule.
66

7-
When a rule has a lot of tests, it's sometimes difficult to tell if any tests are duplicates. This rule would warn if any test cases have the same properties.
7+
Duplicate test cases can cause confusion, can be hard to detect manually in a long file, and serve no purpose.
8+
9+
As of [ESLint v9](https://github.com/eslint/rfcs/tree/main/designs/2021-stricter-rule-test-validation#disallow-identical-test-cases), ESLint attempts to detect and disallow duplicate tests.
810

911
## Rule Details
1012

13+
This rule detects duplicate test cases.
14+
1115
Examples of **incorrect** code for this rule:
1216

1317
```js
1418
/* eslint eslint-plugin/no-identical-tests: error */
1519

1620
new RuleTester().run('foo', bar, {
17-
valid: [{ code: 'foo' }, { code: 'foo' }],
18-
invalid: [],
21+
valid: [
22+
'foo',
23+
'foo', // duplicate of previous
24+
],
25+
invalid: [
26+
{ code: 'bar', errors: [{ messageId: 'my-message', type: 'CallExpression' }] },
27+
{ code: 'bar', errors: [{ messageId: 'my-message', type: 'CallExpression' }] } // duplicate of previous
28+
],
1929
});
2030
```
2131

@@ -25,11 +35,7 @@ Examples of **correct** code for this rule:
2535
/* eslint eslint-plugin/no-identical-tests: error */
2636

2737
new RuleTester().run('foo', bar, {
28-
valid: [{ code: 'foo' }, { code: 'bar' }],
38+
valid: ['foo', 'bar'],
2939
invalid: [],
3040
});
3141
```
32-
33-
## When Not To Use It
34-
35-
If you want to allow identical tests, do not enable this rule.

0 commit comments

Comments
 (0)