Skip to content
masterclass Buddy

Vitest · Function

onTestFinished

onTestFinished registers cleanup that runs after a test ends. It is useful for closing resources and restoring state, including when a test fails.

Last updated

Syntax

function onTestFinished(callback: () => unknown): void

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

Subscribe
  • TestContext
  • afterEach
  • beforeEach
  • onTestFailed
  • using
  • restoreMocks

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