vitest/max-expects

March 1, 2026 ยท View on GitHub

๐Ÿ“ Enforce a maximum number of expect per test.

โš ๏ธ This rule warns in the ๐ŸŒ all config.

Rule Details

Examples of incorrect code for this rule with max: 1:

test('foo', () => {
  expect(1).toBe(1)
  expect(2).toBe(2)
})

Examples of correct code for this rule:

test('foo', () => {
  expect(1).toBe(1)
})

Options

NameDescriptionType
maxMaximum number of expect calls allowed in a test.Number

Default: 5

Maximum number of expect per test.

{
  max: number
}