source: frontend/node_modules/eslint-plugin-jest/docs/rules/no-duplicate-hooks.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.2 KB
Line 
1# Disallow duplicate setup and teardown hooks (`no-duplicate-hooks`)
2
3A `describe` block should not contain duplicate hooks.
4
5## Rule Details
6
7Examples of **incorrect** code for this rule
8
9```js
10/* eslint jest/no-duplicate-hooks: "error" */
11
12describe('foo', () => {
13 beforeEach(() => {
14 // some setup
15 });
16 beforeEach(() => {
17 // some setup
18 });
19 test('foo_test', () => {
20 // some test
21 });
22});
23
24// Nested describe scenario
25describe('foo', () => {
26 beforeEach(() => {
27 // some setup
28 });
29 test('foo_test', () => {
30 // some test
31 });
32 describe('bar', () => {
33 test('bar_test', () => {
34 afterAll(() => {
35 // some teardown
36 });
37 afterAll(() => {
38 // some teardown
39 });
40 });
41 });
42});
43```
44
45Examples of **correct** code for this rule
46
47```js
48/* eslint jest/no-duplicate-hooks: "error" */
49
50describe('foo', () => {
51 beforeEach(() => {
52 // some setup
53 });
54 test('foo_test', () => {
55 // some test
56 });
57});
58
59// Nested describe scenario
60describe('foo', () => {
61 beforeEach(() => {
62 // some setup
63 });
64 test('foo_test', () => {
65 // some test
66 });
67 describe('bar', () => {
68 test('bar_test', () => {
69 beforeEach(() => {
70 // some setup
71 });
72 });
73 });
74});
75```
Note: See TracBrowser for help on using the repository browser.