Change8

v5.0.0-rc.1

Breaking Changes
📦 vitestView on GitHub →
8 breaking3 features🐛 18 fixes🔧 7 symbols

Summary

Vitest v1.5 introduces significant changes to project configuration, asynchronous assertion handling, and browser mode capabilities. It also includes numerous bug fixes and performance improvements.

⚠️ Breaking Changes

  • Inline projects now extend the root config by default. This change might affect configurations where inline projects were intended to have completely separate configurations.
  • Mocking Temporal is now enabled without requiring fake timers. This might break existing tests that relied on fake timers for Temporal mocking.
  • Nested projects are now supported. This could alter how project configurations are resolved or inherited.
  • The separator for the `-t` (test name pattern) flag has changed from a space to `>`. Tests using space-separated patterns will need to be updated.
  • Asynchronous assertions that are not awaited will now cause the test to fail. Ensure all promises returned by assertions are properly awaited.
  • The Vite server is now shared between inline projects. This could impact isolation between inline projects if they rely on distinct server states.
  • In browser mode, failure screenshots are now saved in `attachmentsDir`. Existing paths or expectations for screenshots might need adjustment.
  • Spy mocks now preserve class mock prototype methods on instances. This might change behavior for tests relying on specific prototype interactions with mocked classes.

Migration Steps

  1. Update test patterns using spaces with the `-t` flag to use `>` as a separator.
  2. Ensure all asynchronous assertions return promises that are properly awaited.

✨ New Features

  • Duration breakdown is now reported as percentages.
  • Added a shorthand `-p` for the `--project` CLI flag.
  • Support for `require(esm)` in vm pools has been added.

🐛 Bug Fixes

  • Coalesced concurrent watch-mode restarts and deflaked the pool stderr fixture.
  • Prevented `vitest --typecheck` from reporting false success when the `tsc` process crashes.
  • Collected in-source tests when the module is cached.
  • Swapped `replace()` arguments so timeout error stacks show the real message.
  • Fixed stale mock metadata breaking automocking with `isolate:false`.
  • Prevented losing worker output on teardown and deflaked timing-sensitive tests.
  • In browser mode, ignored channel events in a tester opened as a top-level window.
  • In browser mode, resolved `connectTimeout` from the project config.
  • In browser mode, prebundled the Vite module runner with Vitest.
  • In browser mode, restored the dependency reload warning.
  • In browser mode, configured internal optimizer dependencies.
  • Improved `fsModuleCache` resiliency during external modifications.
  • In CLI, added exit on `CTRL+c` even when `globalSetup` runs blocked code.
  • Handled nullish `toHaveProperty` values.
  • In reporters, printed parent describe suites when the passed-test list is hidden.
  • In runner, avoided failing collection when accessing `error.stack` throws.
  • In spy, pointed ESM namespace spy errors to module mocking docs.
  • In typecheck, reported a checker crash on Windows instead of a spawn failure.

Affected Symbols