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
| Name | What it does |
|---|
describe | Function |
it | Function |
expect | Function |
beforeEach | Function |
afterEach | Function |
vi.fn | Function |
vi.mock | Function |
vi.spyOn | Function |
test | Function |
bench | Function |
expectTypeOf | Function |
assertType | Function |
suite | Function |
beforeAll | Function |
afterAll | Function |
test.each | Function |
test.skip | Function |
test.only | Function |
test.todo | Function |
test.concurrent | Function |
test.runIf | Function |
test.skipIf | Function |
onTestFinished | Function |
onTestFailed | Function |
defineConfig | Function |
mergeConfig | Function |
Type Alias
| Name | What it does |
|---|
Mock | Type Alias |
MockInstance | Type Alias |
TestContext | Type Alias |
UserConfig | Type Alias |
Module
| Name | What it does |
|---|
vi.stubGlobal | Module |
vi.stubEnv | Module |
vi.unstubAllGlobals | Module |
vi.useFakeTimers | Module |
vi.useRealTimers | Module |
vi.advanceTimersByTime | Module |
vi.runAllTimers | Module |
vi.clearAllMocks | Module |
vi.resetAllMocks | Module |
vi.restoreAllMocks | Module |
vi.mocked | Module |
vi.importActual | Module |
vi.importMock | Module |
vi.hoisted | Module |
vi.waitFor | Module |
vi.waitUntil | Module |
vi.setConfig | Module |
vi.doMock | Module |
vi.resetModules | Module |
toBe | Module |
toEqual | Module |
toStrictEqual | Module |
toMatchObject | Module |
toContain | Module |
toThrow | Module |
toMatchSnapshot | Module |
toMatchInlineSnapshot | Module |
toHaveBeenCalled | Module |
toHaveBeenCalledWith | Module |
toMatchFileSnapshot | Module |
toSatisfy | Module |
resolves | Module |
rejects | Module |
soft | Module |
toEqualTypeOf | Module |
toMatchTypeOf | Module |
toBeString | Module |
toBeNumber | Module |
parameters | Module |
returns | Module |
toBeCallableWith | Module |
vi.advanceTimersByTimeAsync | Module |
vi.runAllTimersAsync | Module |
vi.runOnlyPendingTimers | Module |
vi.getMockName | Module |
vi.isMockFunction | Module |
vi.clearAllTimers | Module |
vi.setSystemTime | Module |
vi.getRealSystemTime | Module |
toBeTypeOf | Module |
toBeOneOf | Module |
toHaveResolved | Module |
toHaveResolvedWith | Module |
toThrowErrorMatchingSnapshot | Module |
Pipe
| Name | What it does |
|---|
test.globals | Pipe |
test.environment | Pipe |
test.coverage | Pipe |
test.setupFiles | Pipe |
test.include | Pipe |
test.exclude | Pipe |
test.pool | Pipe |
test.workspace | Pipe |
test.browser | Pipe |
test.reporters | Pipe |
test.deps | Pipe |
test.alias | Pipe |
Command
| Name | What it does |
|---|
vitest run | Command |
vitest watch | Command |
vitest --ui | Command |
vitest bench | Command |
vitest --coverage | Command |
vitest related | Command |
Search across every package and filter by type in your dashboard.
Start learning