source: frontend/node_modules/eslint-plugin-jest/docs/rules/no-identical-title.md

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.4 KB
Line 
1# Disallow identical titles (`no-identical-title`)
2
3Having identical titles for two different tests or test suites may create
4confusion. For example, when a test with the same title as another test in the
5same test suite fails, it is harder to know which one failed and thus harder to
6fix.
7
8## Rule Details
9
10This rule looks at the title of every test and test suites. It will report when
11two test suites or two test cases at the same level of a test suite have the
12same title.
13
14The following patterns are considered warnings:
15
16```js
17describe('foo', () => {
18 it('should do bar', () => {});
19 it('should do bar', () => {}); // Has the same title as the previous test
20
21 describe('baz', () => {
22 // ...
23 });
24
25 describe('baz', () => {
26 // Has the same title as a previous test suite
27 // ...
28 });
29});
30```
31
32These patterns would not be considered warnings:
33
34```js
35describe('foo', () => {
36 it('should do foo', () => {});
37 it('should do bar', () => {});
38
39 // Has the same name as a parent test suite, which is fine
40 describe('foo', () => {
41 // Has the same name as a test in a parent test suite, which is fine
42 it('should do foo', () => {});
43 it('should work', () => {});
44 });
45
46 describe('baz', () => {
47 // Has the same title as a previous test suite
48 // Has the same name as a test in a sibling test suite, which is fine
49 it('should work', () => {});
50 });
51});
52```
Note: See TracBrowser for help on using the repository browser.