noDuplicateTestHooks
Este conteúdo não está disponível em sua língua ainda.
Diagnostic Category: lint/suspicious/noDuplicateTestHooks
Since: v1.6.0
Sources:
- Inspired from:
jest/no-duplicate-hooks
Description
Section titled DescriptionA describe
block should not contain duplicate hooks.
Examples
Section titled ExamplesInvalid
Section titled Invaliddescribe('foo', () => { beforeEach(() => { // some setup }); beforeEach(() => { // some setup }); test('foo_test', () => { // some test });});
code-block.js:5:3 lint/suspicious/noDuplicateTestHooks ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Disallow duplicate setup and teardown hooks.
3 │ // some setup
4 │ });
> 5 │ beforeEach(() => {
│ ^^^^^^^^^^^^^^^^^^
> 6 │ // some setup
> 7 │ });
│ ^^
8 │ test(‘foo_test’, () => {
9 │ // some test
ℹ Disallow beforeEach duplicacy inside the describe function.
describe('foo', () => { beforeEach(() => { // some setup }); test('foo_test', () => { afterAll(() => { // some teardown }); afterAll(() => { // some teardown }); });});
code-block.js:9:4 lint/suspicious/noDuplicateTestHooks ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Disallow duplicate setup and teardown hooks.
7 │ // some teardown
8 │ });
> 9 │ afterAll(() => {
│ ^^^^^^^^^^^^^^^^
> 10 │ // some teardown
> 11 │ });
│ ^^
12 │ });
13 │ });
ℹ Disallow afterAll duplicacy inside the describe function.
Valid
Section titled Validdescribe('foo', () => { beforeEach(() => { // some setup }); test('foo_test', () => { // some test });});
How to configure
Section titled How to configure{ "linter": { "rules": { "suspicious": { "noDuplicateTestHooks": "error" } } }}