v4.1.0
📦 vitestView on GitHub →
✨ 36 features🔧 14 symbols
Summary
Vitest 4.1 introduces numerous features including chai style assertions, support for tags, new browser APIs, and updates to underlying dependencies like sinon/fake-timers v15. This version also stabilizes experimental features and improves compatibility with Vite 8 beta.
Migration Steps
- If you rely on the return value of `doMock()`, update your code to handle the returned disposable object.
✨ New Features
- Return a disposable from doMock().
- Added chai style assertions.
- Update to sinon/fake-timers v15 and add `setTickMode` to timer controls.
- Expose matcher types.
- Add `toTestSpecification` to reported tasks.
- Show a warning if `vi.mock` or `vi.hoisted` are declared outside of top level of the module.
- Track and display expectedly failed tests (.fails) in UI and CLI.
- Support tags.
- Implement `aroundEach` and `aroundAll` hooks.
- Stabilize experimental features.
- Accept `new` or `all` in --update flag.
- Support `meta` in test options.
- Support type inference with a new `test.extend` syntax.
- Support vite 8 beta, fix type issues in the config with different vite versions.
- Add assertion helper to hide internal stack traces.
- Store failure screenshots using artifacts API.
- Allow `vitest list` to statically collect tests instead of running files to collect them.
- Add --detect-async-leaks.
- Implement `mockThrow` and `mockThrowOnce`.
- Support `update: "none"` and add docs about snapshots behavior on CI.
- Support playwright `launchOptions` with `connectOptions`.
- Add `page/locator.mark` API to enhance playwright trace.
- API: Support tests starting or ending with `test` in `experimental_parseSpecification`.
- API: Add filters to `createSpecification`.
- API: Expose `runTestFiles` as alternative to `runTestSpecifications`.
- API: Add `allowWrite` and `allowExec` options to `api`.
- API: Allow passing down test cases to `toTestSpecification`.
- Browser: Add `userEvent.wheel` API.
- Browser: Add `filterNode` option to prettyDOM for filtering browser assertion error output.
- Browser: Support playwright persistent context.
- Browser: Added `detailsPanelPosition` option and button.
- Browser: Use BlazeDiff instead of pixelmatch.
- Browser: Add `findElement` and enable strict mode in webdriverio and preview.
- CLI: Add @bomb.sh/ tab completions.
- Coverage: Support `ignore start/stop` ignore hints.
- Coverage: Add `coverage.changed` option to report only changed files.