Skip to content
masterclass Buddy

Vitest · Function

afterEach

afterEach runs cleanup after every test in the current file or suite. Vitest waits for asynchronous cleanup before continuing.

Last updated

Syntax

function afterEach(body: (context: TestContext) => unknown, timeout?: number): void

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • beforeEach
  • beforeAll
  • afterAll
  • onTestFinished
  • hookTimeout

Source: Hooks | Vitest. Checked 2026-11-03.