Change8

v4.0.0-beta.2

Breaking Changes
📦 vitestView on GitHub →
5 breaking1 features🐛 2 fixes🔧 6 symbols

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.

⚠️ Breaking Changes

  • Support for Vite 5 has been removed. Projects using Vite 5 must downgrade to Vite 4 or adjust the integration accordingly.
  • Deprecated type definitions have been removed. Update code to use the new type definitions provided by Vitest.
  • The configuration options `environmentMatchGlobs` and `poolMatchGlobs` have been removed. Replace them with the new `environment` and `pool` configuration patterns.
  • Snapshot tests now fail on CI when an obsolete snapshot is detected. Update CI pipelines to treat snapshot failures as errors or regenerate snapshots.
  • `spy` now supports spying on classes, which changes the API surface. Adjust existing spy usage to accommodate class spying semantics.

Migration Steps

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

✨ New Features

  • Introduced `onUnhandledError` callback, allowing users to handle uncaught errors in test runs.

🐛 Bug Fixes

  • Globals can now be overridden in type definitions.
  • In browser mode, in‑source tests are executed only when the file itself is a test file.

🔧 Affected Symbols

ViteenvironmentMatchGlobspoolMatchGlobssnapshotspyonUnhandledError