Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

API reference

Vitest API reference

Vitest testing for Vite projects

Identifiers
103
With full guides
0
Types
6

Topics covered

  • Setup with Vite
  • Matchers
  • Mocking with vi
  • Component testing
  • Coverage
  • In-source testing
  • Snapshots
  • Benchmarking

Function

NameWhat it does
describeFunction
itFunction
expectFunction
beforeEachFunction
afterEachFunction
vi.fnFunction
vi.mockFunction
vi.spyOnFunction
testFunction
benchFunction
expectTypeOfFunction
assertTypeFunction
suiteFunction
beforeAllFunction
afterAllFunction
test.eachFunction
test.skipFunction
test.onlyFunction
test.todoFunction
test.concurrentFunction
test.runIfFunction
test.skipIfFunction
onTestFinishedFunction
onTestFailedFunction
defineConfigFunction
mergeConfigFunction

Type Alias

NameWhat it does
MockType Alias
MockInstanceType Alias
TestContextType Alias
UserConfigType Alias

Const

NameWhat it does
viConst

Module

NameWhat it does
vi.stubGlobalModule
vi.stubEnvModule
vi.unstubAllGlobalsModule
vi.useFakeTimersModule
vi.useRealTimersModule
vi.advanceTimersByTimeModule
vi.runAllTimersModule
vi.clearAllMocksModule
vi.resetAllMocksModule
vi.restoreAllMocksModule
vi.mockedModule
vi.importActualModule
vi.importMockModule
vi.hoistedModule
vi.waitForModule
vi.waitUntilModule
vi.setConfigModule
vi.doMockModule
vi.resetModulesModule
toBeModule
toEqualModule
toStrictEqualModule
toMatchObjectModule
toContainModule
toThrowModule
toMatchSnapshotModule
toMatchInlineSnapshotModule
toHaveBeenCalledModule
toHaveBeenCalledWithModule
toMatchFileSnapshotModule
toSatisfyModule
resolvesModule
rejectsModule
softModule
toEqualTypeOfModule
toMatchTypeOfModule
toBeStringModule
toBeNumberModule
parametersModule
returnsModule
toBeCallableWithModule
vi.advanceTimersByTimeAsyncModule
vi.runAllTimersAsyncModule
vi.runOnlyPendingTimersModule
vi.getMockNameModule
vi.isMockFunctionModule
vi.clearAllTimersModule
vi.setSystemTimeModule
vi.getRealSystemTimeModule
toBeTypeOfModule
toBeOneOfModule
toHaveResolvedModule
toHaveResolvedWithModule
toThrowErrorMatchingSnapshotModule

Pipe

NameWhat it does
test.globalsPipe
test.environmentPipe
test.coveragePipe
test.setupFilesPipe
test.includePipe
test.excludePipe
test.poolPipe
test.workspacePipe
test.browserPipe
test.reportersPipe
test.depsPipe
test.aliasPipe

Command

NameWhat it does
vitest runCommand
vitest watchCommand
vitest --uiCommand
vitest benchCommand
vitest --coverageCommand
vitest relatedCommand

Search across every package and filter by type in your dashboard.

Start learning