A describe
block should not contain duplicate hooks.
Examples of incorrect code for this rule
/* eslint playwright/no-duplicate-hooks: "error" */
test.describe('foo', () => {
test.beforeEach(() => {
// some setup
})
test.beforeEach(() => {
// some setup
})
test('foo_test', () => {
// some test
})
})
// Nested describe scenario
test.describe('foo', () => {
test.beforeEach(() => {
// some setup
})
test('foo_test', () => {
// some test
})
test.describe('bar', () => {
test('bar_test', () => {
test.afterAll(() => {
// some teardown
})
test.afterAll(() => {
// some teardown
})
})
})
})
Examples of correct code for this rule
/* eslint playwright/no-duplicate-hooks: "error" */
test.describe('foo', () => {
test.beforeEach(() => {
// some setup
})
test('foo_test', () => {
// some test
})
})
// Nested describe scenario
test.describe('foo', () => {
test.beforeEach(() => {
// some setup
})
test('foo_test', () => {
// some test
})
test.describe('bar', () => {
test('bar_test', () => {
test.beforeEach(() => {
// some setup
})
})
})
})