-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rules): no-duplicate-hooks (#298)
Fixes #231
- Loading branch information
Showing
8 changed files
with
492 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Disallow duplicate setup and teardown hooks (no-duplicate-hooks) | ||
|
||
A describe block should not contain duplicate hooks. | ||
|
||
## Rule Details | ||
|
||
Examples of **incorrect** code for this rule | ||
|
||
```js | ||
/* eslint jest/no-duplicate-hooks: "error" */ | ||
|
||
describe('foo', () => { | ||
beforeEach(() => { | ||
// some setup | ||
}); | ||
beforeEach(() => { | ||
// some setup | ||
}); | ||
test('foo_test', () => { | ||
// some test | ||
}); | ||
}); | ||
|
||
// Nested describe scenario | ||
describe('foo', () => { | ||
beforeEach(() => { | ||
// some setup | ||
}); | ||
test('foo_test', () => { | ||
// some test | ||
}); | ||
describe('bar', () => { | ||
test('bar_test', () => { | ||
afterAll(() => { | ||
// some teardown | ||
}); | ||
afterAll(() => { | ||
// some teardown | ||
}); | ||
}); | ||
}); | ||
}); | ||
``` | ||
|
||
Examples of **correct** code for this rule | ||
|
||
```js | ||
/* eslint jest/no-duplicate-hooks: "error" */ | ||
|
||
describe('foo', () => { | ||
beforeEach(() => { | ||
// some setup | ||
}); | ||
test('foo_test', () => { | ||
// some test | ||
}); | ||
}); | ||
|
||
// Nested describe scenario | ||
describe('foo', () => { | ||
beforeEach(() => { | ||
// some setup | ||
}); | ||
test('foo_test', () => { | ||
// some test | ||
}); | ||
describe('bar', () => { | ||
test('bar_test', () => { | ||
beforeEach(() => { | ||
// some setup | ||
}); | ||
}); | ||
}); | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.