Built-in Test Context in Vitest
From the Vitest cheat sheet ยท Test Context & Fixtures ยท verified Nov 2026
Built-in Test Context
task, expect, skip, signal, annotate, and per-test hooks from the first test argument
typescript
test('context', ({ task, expect, skip, signal, onTestFinished }) => {
console.log(task.name) // 'context'
skip(!process.env.API_KEY, 'needs API_KEY')
onTestFinished(() => cleanup())
})๐ The first test argument is the context; destructure what you need
๐ก Use the context expect in concurrent tests for correct snapshots
โก Pass signal to fetch so a timed-out test stops its request
๐ v5 also puts a bench fixture on the context for benchmarks
test-contexttasksignal
Continue with Vitest
Save the full cheat sheet or work through every related task.