Change8

Migrating to Vitest v4.0.0-beta.2

Version v4.0.0-beta.2 introduces 5 breaking changes. This guide details how to update your code.

Released: 6/24/2025

5
Breaking Changes
5
Migration Steps
6
Affected Symbols

⚠️ Check Your Code

If you use any of these symbols, you need to read this guide:

ViteenvironmentMatchGlobspoolMatchGlobssnapshotspyonUnhandledError

Breaking Changes

Issue #1

Support for Vite 5 has been removed. Projects using Vite 5 must downgrade to Vite 4 or adjust the integration accordingly.

Issue #2

Deprecated type definitions have been removed. Update code to use the new type definitions provided by Vitest.

Issue #3

The configuration options `environmentMatchGlobs` and `poolMatchGlobs` have been removed. Replace them with the new `environment` and `pool` configuration patterns.

Issue #4

Snapshot tests now fail on CI when an obsolete snapshot is detected. Update CI pipelines to treat snapshot failures as errors or regenerate snapshots.

Issue #5

`spy` now supports spying on classes, which changes the API surface. Adjust existing spy usage to accommodate class spying semantics.

Migration Steps

  1. 1
    Remove any Vite 5 specific configuration or plugins; switch to a supported Vite version.
  2. 2
    Update imports and type usages to reflect the removal of deprecated types.
  3. 3
    Replace `environmentMatchGlobs` and `poolMatchGlobs` with the recommended `environment` and `pool` configuration options.
  4. 4
    Ensure CI pipelines treat failing obsolete snapshots as errors or run `vitest -u` to update snapshots.
  5. 5
    Review spy usage; if spying on classes, adapt to the new API or use the previous function‑spying approach.

Release Summary

Vitest v4.0.0-beta.2 removes Vite 5 support and several deprecated APIs, adds an `onUnhandledError` callback, and includes bug fixes for globals overriding and browser test detection.

Need More Details?

View the full release notes and all changes for Vitest v4.0.0-beta.2.

View Full Changelog