Skip to content

Latest commit

 

History

History
62 lines (39 loc) · 1.08 KB

require-top-level-describe.md

File metadata and controls

62 lines (39 loc) · 1.08 KB

Enforce that all tests are in a top-level describe (vitest/require-top-level-describe)

⚠️ This rule warns in the 🌐 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.

Options

This rule accepts an object with the following properties:

  • maxNumberOfTopLevelDescribes: The maximum number of top-level tests allowed in a file. Defaults to Infinity. 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', () => {})
		})
	})
})