Packages

@vitest/spy

5.0.5 · 15 Oct 2026MIT202.7M / weekRepositoryHomepagenpmAtom feed

Your version

3.0.0

major16 Jan 2025Where it was published

3.2.7 is the newest release of 3.x.

In short

11 breaking39 new59 fixed1 internal

  • breaking

    There are a few breaking changes, but we expect the migration to be smooth.

  • breaking

    spy.mockReset changes

  • breaking

    Pass down context to test hooks

  • breaking

    Support Vite 6

  • breaking

    coverage: Always exclude test files

  • breaking

    deps: Update fake-timers to v14.0.0

  • breaking

    expect: Check more properties for error equality

  • breaking

    runner: Support describe(..., { shuffle: boolean }) and inherit from parent suite

Release note

Vitest 3 is here! There are a few breaking changes, but we expect the migration to be smooth. This release page lists all changes made to the project during the beta. For the migration guide, please refer to the documentation.

Breaking Changes

  • breaking

    spy.mockReset changes

  • breaking

    Pass down context to test hooks

  • breaking

    Support Vite 6

  • breaking

    coverage: Always exclude test files

  • breaking

    deps: Update fake-timers to v14.0.0

  • breaking

    expect: Check more properties for error equality

  • breaking

    runner: Support describe(..., { shuffle: boolean }) and inherit from parent suite

  • breaking

    snapshot: Reset snapshot state for retry and repeats

  • breaking

    spy: SpyOn reuses mock if method is already spyed on

  • breaking

    vitest: Don't expose default toFake config

Features

  • Support inline diff options and support printBasicPrototype

  • Allow a custom note when calling ctx.skip() dynamically

  • Allow inline workspace configuration

  • Provide the current project to the global setup

  • Print project name as a label

  • Print a deprecation warning if suite or test uses object as the third argument

  • Expose versions from vitest/node entry point and statically on Vitest

  • diff.printBasicPrototype: false by default

  • Prepare the Vitest API to be stable

  • Support Vite v6 in mocker package

  • Allow multi-browser configuration

  • Add resolved project names to the reporter API

  • Introduce the new reporter API

  • Add describe.for

  • api: Add onBrowserInit event

  • browser: Support actionTimeout as playwright provider options

  • browser: Support clipboard api userEvent.copy, cut, paste

  • browser: Implement locator.nth()

  • cli: Support excluding projects with --project=!pattern

  • cli: Support specifying a line number when filtering tests

  • cli: Support location filters for suites

  • coverage: thresholds to support maximum uncovered items

  • expect: Add toHaveBeenCalledExactlyOnceWith expect matcher

  • expect: Add toHaveBeenCalledAfter and toHaveBeenCalledBefore utility

  • expect: Add toSatisfy asymmetric matcher

  • expect: Add toBeOneOf matcher

  • reporter: Add support for function type to classname option in the junit reporter

  • reporters: summary option for verbose and default reporters

  • runner: Test context can inject values from the config's provide

  • runner: Add "queued" state

  • snapshot: Provide config to resolveSnapshotPath

  • ui: Allow run individual tests/suites from the UI

  • ui: Make clicking on a test in the UI open the report section and scroll to the test failure if applicable

  • ui: Allow hide/show node_modules in module graph tab

  • vitest: Include coverageMap in json report

  • vitest: Add onTestsRerun method to global setup context

Bug Fixes

  • Misc fix for vite 6 ecosystem ci

  • Respect cacheDir when optimizer is enabled

  • Reset runningPromise after finally in case there is an error to avoid it getting stuck

  • Revert support for Vite 6

  • Support Node 21

  • Don't use Custom type internally

  • Persist cli filters as watch mode file filter

  • Don't use dim color for succeeded tests

  • Fix missing chai types

  • cancelCurrentRun awaits runningPromise

  • Add Locator typings for nth, first and last.

  • Batch console logs by microtask

  • Allow getMockImplementation to return "once" implementation

  • capturePrintError logger duplicate event handlers

  • Allow slots in vitest-browser-vue

  • Reset root workspace project on restart

  • Cleanup vitest/reporters entrypoint

  • Colors on forks pool

  • Export VitestRunner type from vitest/runners

  • Return test fn result to runner

  • Re-apply default conditions if using vite 6 or later

  • Prevent infinite loop on prettyDOM calls

  • api: Don't report events during vitest list

  • benchmark: Disable type testing while benchmarking

  • benchmark: Rewrite reporter without log-update

  • browser: Improve source maps when vi.mock is present

  • browser: Explain TypeScript support in docs and add asymmetric matchers to types

  • browser: Fix matchers.d.ts

  • browser: Fix user event state on preview provider

  • browser: Fix provider options types

  • browser: Only use locator.element on last expect.element attempt

  • browser: Use correct project when filtering entries in the browser mode

  • browser: Fix console.time with fake timers

  • browser: Add instance validation to resolve coverage error

  • coverage: Exclude browser mode iframe results

  • coverage: Correct coverage when isolate: false is used

  • coverage: Prevent crash when v8 incorrectly merges static_initializer's

  • deps: Update all non-major dependencies - in #7085

  • deps: Update all non-major dependencies - in #7116

  • diff: Truncate to avoid crash on diff large objects

  • junit: Fix testsuites time to be sum of all testsuite items

  • pretty-format: Support react 19

  • reporters: Write buffered stdout/stderr on process exit

  • reporters: Rewrite dot reporter without log-update

  • reporters: Check --hideSkippedTests in base reporter

  • reporters: Show retry and repeats counts

  • runner: Long synchronous tasks does not time out

  • runner: Mark tests of describe.todo as 'todo'

  • snapshot: Fix "obsolete" message on snapshot update re-run

  • snapshot: Preserve white space of toMatchFileSnapshot

  • snapshot: Fix obsoleteness check of toMatchSnapshot("...")

  • typecheck: Fix typecheck collect on Vite 6

  • typecheck: Use unique temp and tsbuildinfo file for each tsconfig file

  • typecheck: Fix error test case mapping for @ts-expect-error

  • types: Make parameters non-nullable for Playwright options

  • ui: Wrong module graph when generating html.meta.json.gz in browser mode

  • ui: Add errors and draft state (*) to the code editor

  • vite-node: Fix error stack on Windows

  • vite-node: Properly normalize file url import

  • vite-node: Fix mandatory node prefix

  • watch: Don't indicate exit when no matching files

  • workspace: extends: true correctly inherits all root config properties