Pular para o conteúdo

noDuplicateTestHooks

Este conteúdo não está disponível em sua língua ainda.

Diagnostic Category: lint/suspicious/noDuplicateTestHooks

Since: v1.6.0

Sources:

A describe block should not contain duplicate hooks.

describe('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.

describe('foo', () => {
beforeEach(() => {
// some setup
});
test('foo_test', () => {
// some test
});
});