v4.0.0-beta.3
Breaking Changes📦 vitestView on GitHub →
⚠ 2 breaking✨ 4 features🐛 13 fixes🔧 12 symbols
Summary
Vitest v4.0.0-beta.3 adds spy support for mock objects, new expect utilities, and an automocker entry, while removing the deprecated `workspace` option and changing `--standalone` behavior, plus numerous bug fixes and dependency updates.
⚠️ Breaking Changes
- Removed the deprecated `workspace` option; use the new `projects` option instead.
- The `--standalone` flag is ignored when a CLI filename filter is provided, which may change test execution behavior.
Migration Steps
- Replace any usage of the `workspace` configuration option with the new `projects` option.
- If you rely on `--standalone`, ensure you are not also using a CLI filename filter, or remove the filter.
✨ New Features
- Added a `spy` option to `vi.mockObject` for easier spying on mocked objects.
- Browser environment now supports the `toBeInViewport` utility method to assert element visibility within the viewport.
- Expect library now includes `toBeNullable` to check for nullish values.
- Mocker now includes an `automocker` entry for automatic mocking.
🐛 Bug Fixes
- Removed unused dependencies.
- Improved shard distribution to allocate test files more evenly.
- Now uses the suite's timeout when `test.extend` is called.
- Snapshot handling now works without object key sorting.
- Annotation location always points to the test file.
- Fixed `objectContaining` expect utility for better Jest compatibility.
- Coverage now includes files based on `--project` filter.
- Prevented encoding issues for filenames of uncovered files.
- Updated all non-major dependencies.
- Fixed `regexpHoistable` to allow whitespace before parentheses.
- Fixed invisible CLI menus when running `vitest --standalone`.
- Properly disabled the minifier in the browser client for Rolldown-Vite.
- Filename filter no longer runs duplicate tests in workspaces.
🔧 Affected Symbols
workspaceprojects--standalonevi.mockObjectexpect.toBeInViewportexpect.toBeNullablemocker.automockerexpect.objectContainingcoverageregexpHoistablerolldown-vite.minifierwatch.filenameFilter