vitest/expect-expect

March 1, 2026 ยท View on GitHub

๐Ÿ“ Enforce having expectation in test body.

๐Ÿ’ผโš ๏ธ This rule is enabled in the โœ… recommended config. This rule warns in the ๐ŸŒ all config.

Rule Details

This rule aims to enforce having at least one expectation in test body to ensure that the test is actually testing something.

Examples of incorrect code for this rule:

test('myLogic', () => {
  console.log('myLogic')
})

test('myLogic', () => {})

Examples of correct code for this rule:

test('myLogic', () => {
  const actual = myLogic()
  expect(actual).toBe(true)
})

Type-testing

If you're using Vitest's type-testing feature and have tests that only contain expectTypeOf, you will need to enable typecheck in this plugin's settings: Enabling type-testing.

Options

NameDescriptionType
additionalTestBlockFunctionsAdditional functions that should be treated as test blocks.String[]
assertFunctionNamesList of function names treated as assertions.String[]

assertFunctionNames

{
  "vitest/expect-expect": [
    "error",
    {
      "assertFunctionNames": ["expect"],
      "additionalTestBlockFunctions": []
    }
  ]
}

An array of strings that are the names of the functions that are used for assertions. Function names can also be wildcard patterns like expect*,function.**.expect or expect.anything.

The following is an example of correct code for this rule with the option assertFunctionNames:

import CheckForMe from 'check-for-me'
test('myLogic', () => {
  expect('myLogic').toBe('myOutput')
})

additionalTestBlockFunctions

{
  "rules": {
    "vitest/expect-expect": [
      "error",
      { "additionalTestBlockFunctions": ["checkForMe"] }
    ]
  }
}

An array of strings that are the names of the functions that are used for test blocks. Function names can also be wildcard patterns like describe*,function.**.describe or describe.anything.

The following is an example of correct code for this rule with the option additionalTestBlockFunctions:

import CheckForMe from 'check-for-me'
checkForMe('myLogic', () => {
  checkForMe('myLogic', () => {
    const actual = myLogic()
    expect(actual).toBe(true)
  })
})