v4.0.0-beta.10
Breaking Changes📦 vitestView on GitHub →
⚠ 1 breaking✨ 4 features🐛 6 fixes🔧 10 symbols
Summary
Vitest v4.0.0-beta.10 adds a new provider‑factory requirement for browsers, introduces several new API features like `relativeModuleId` and locator length support, and includes multiple bug fixes and performance improvements.
⚠️ Breaking Changes
- browser: Provider configuration now requires a provider factory function instead of a string. Update your browser config to pass a factory (e.g., `provider: () => new MyProvider()`), or migrate existing string values to the new factory format.
Migration Steps
- Replace any browser provider strings with a provider factory function as required by the new API.
- If you used `toHaveLength` with a plain number, you can now pass a locator directly; no code change is required unless you relied on the previous type signature.
- Update any code that constructs `TestModule` objects to use the new `relativeModuleId` field where needed.
- Ensure your project uses tinypool version 2.0.0 or later (the release updates the internal dependency).
- Review your dependency lockfile for the updated non‑major packages and run a fresh install.
✨ New Features
- api: Added `relativeModuleId` property to `TestModule` for easier relative module resolution.
- browser: Added support for iframe locator when using the Playwright provider.
- browser: Locators now expose a `length` property and `toHaveLength` matcher accepts locators directly.
- coverage: `autoUpdate` now supports percentage formatting.
🐛 Bug Fixes
- Added support for `import.meta.resolve` on Vite 7.
- When an `expect.poll` assertion fails, the original assertion error is shown first.
- Fake timers are correctly overridden when `useFakeTimers` is called multiple times.
- Updated all non‑major dependencies to their latest compatible versions.
- Runner is no longer bundled with utils, reducing bundle size.
- Fixed `spyOn` type definitions to handle optional methods correctly.
🔧 Affected Symbols
browser.providerFactoryTestModule.relativeModuleIdLocator.lengthtoHaveLengthcoverage.autoUpdateimport.meta.resolveexpect.polluseFakeTimersrunnerspyOn