all
config.
This rule triggers warning if a test case (test
and it
) or a hook (beforeAll
, beforeEach
, afterEach
, afterAll
) is not located in a top-level describe
block.
This rule accepts an object with the following properties:
maxNumberOfTopLevelDescribes
: The maximum number of top-level tests allowed in a file. Defaults toInfinity
. Allowing any number of top-level describe blocks.
{
"vitest/require-top-level-describe": [
"error",
{
"maxNumberOfTopLevelDescribes": 2
}
]
}
The following patterns are considered warnings:
test('foo', () => {})
beforeEach(() => {
describe('bar', () => {
test('baz', () => {})
})
})
The following patterns are not considered warnings:
describe('foo', () => {
test('bar', () => {})
})
describe('foo', () => {
beforeEach(() => {
describe('bar', () => {
test('baz', () => {})
})
})
})