@vitest/expect
5.0.5 · 15 Oct 2026MIT151.9M / weekRepositoryHomepagenpmAtom feed
2.1.9 is the newest release of 2.x.
In short
20 breaking1 removed38 new63 fixed1 internal
- breaking
Simplify mock function generic types and align with jest - by @hi-ogawa
- breaking
Remove
--segfault-retry - breaking
Run suite hooks in a stack
- breaking
⚠️ This change may cause significant differences in your coverage results compared to Vitest v1. These changes are expected as coverage reporting is now more accurate. See #5423 for more details.
- breaking
Add correct location and snapshot fields in json reporter
- breaking
Update dependency chai to v5 - by renovate[bot] and @sheremet-va in #5135
- breaking
Remove watchExclude
- breaking
Change default
poolto'forks'
Release note
Vitest 2.0 is here! This release page lists all changes made to the project during the beta. For the migration guide, please refer to the documentation.
Breaking Changes
- breaking
Simplify mock function generic types and align with jest - by @hi-ogawa
- breaking
Remove
--segfault-retryThis flag was introduced to combat
threadssegfaults. Our current recommendation is to use the new defaultforkspool instead.
- breaking
Run suite hooks in a stack
This feels like a more sensible default. Especially with the new
onTestFinishedhook. This can make your tests run a little bit slower.
- breaking
Enable
coverage.ignoreEmptyLinesby default⚠️ This change may cause significant differences in your coverage results compared to Vitest v1. These changes are expected as coverage reporting is now more accurate. See #5423 for more details.
- breaking
Add correct location and snapshot fields in json reporter
Previously, the
locationfield pointed to the error location instead of the test location. Now it is aligned with jest and contains thelineandcolumnof a test function, but requiresincludeTaskLocationto be enabled.
- breaking
Update dependency chai to v5 - by renovate[bot] and @sheremet-va in #5135
- breaking
Remove watchExclude
- breaking
Change default
poolto'forks'This change is done for compatibility issues
This pool may be slightly slower than previous
threadspool: vitest.dev/guide/improving-performance.html
- breaking
--merge-reportsto support coverage - breaking
Add promise-based return assertions, do not auto-resolve returned promises
⚠️ Vitest no longer unwraps promises in
spy.mock.returns. If the function is async or returns a promise, it will always succeed and have aPromiseinresults. To make migration easier, we introducedspy.mock.settledResultsthat unwraps promises andexpect().toHaveResolved()matcher that accepts unwrapped value.
- breaking
Do not exit process if global setup has failed
- breaking
Don't exit process if config failed
- breaking
Add meta to
jsonoutput - breaking
Rename
indexScriptstoorchestratorScriptsin the browser config - breaking
Add "vitest list" API to print collected tests without running them
⚠️ This changes the custom
poolAPI - now requirescollectTestsmethod alongsiderunTests.
- breaking
Remove the empty suite from the runner
- breaking
Support concurrent suites - by @hi-ogawa
- breaking
Support overriding
excludein coverage⚠️ Vitest coverage no longer adds test files to
excludepatterns ifcoverage.excludewas overridden in the config. Add your test patterns manually, or merge your overrides with default ones:['**/my-pattern.js', ...coverageConfigDefaults.exclude]. See vitest.dev/config/ for an example.
- breaking
api: Remove
process.exitif workspace project failed to be created - breaking
api: Don't call
process.exitmanually
Features
browser: 🌐 This release lays the groundwork for the next iteration of Vitest Browser Mode. You can read more about our future plans at github.com/vitest-dev/vitest/discussions/5828
browser: Add commands to communicate betweens server and the browser
browser: Do not reload the page during watch mode
browser: Support changing the viewport
browser: Add browser iframe mouse interaction
browser: Support
clickeventbrowser: Rename none provider to preview, make it default
browser: Run tests in parallel in headless mode, add
page.screenshotmethodbrowser: Implement several
userEventmethods, addfillanddragAndDropeventsbrowser: Introduce
expect.dommethod and bundlejest-dommatchers with@vitest/browserbrowser: Expose CDP in the browser
browser: Add "init" command for browser tests
browser: Add an option to take screenshots if the browser test fails
browser: Add
tripleClickto interactive apibrowser: Playwright provider doesn't allow resizing the browser viewport
Pretty print diffs coming from cause
Allow import statement as vi.mock path for better IDE support
- removed
Remove deprecated options
Add blob reporter
✅ Run Vitest in separate processes with
--reporter=blobflag to generate reports and combine them withvitest --merge-reportslater!
Add expect.poll utility
Add browser.ui option
Add median to
--output-jsonAllow augmenting config.test.env
Implement module mocking in browser mode
Allow configuring expect options in the config
Add an option to print console stack trace
Add browser frame to UI
Image type add bmp - by btea in #5921
Add an option to return base64 from page.screenshot
Expose
parseAst,parseAstAsyncfrom viteconfig: Allow percentage value for workers option
runner: Implement
test.forspy: Collect mock.contexts
ui: Render tests in a tree
ui: Load module graph on tab selection
ui: Replace navigation tree with test explorer
ui: Add initializing explorer logic
ui: Add action to explorer item to show the test/suite line in the source code tab
ws-client: Allow change reactive for state, filesMap and idMap
Bug Fixes
Print console statements in vmThreads
Repeatable
--excludeoptionRemove browser.fileParallelism
Install UI icons
Vi.waitFor/vi.waitUntil interval is now cleared after it times out
ToJSON recursive error serialization
Print error properties only in verbose reporter
Use TTY reporter when running in Deno
Don't override uppercase
Clear screen and scrollback on iTerm2
Include pretty-format in @vitest/runner for optimization on npm
Transpile esnext to node18 to support newest JS and TS features
api: Correct
project.providetypebrowser: Display UI
browser: Browser actions icons colors
browser: Restore the original viewport when unselecting the preset viewport
browser: Don't get stuck after the manual page refresh
browser: Use iframe id instead of calculating it from filenames
browser: Always clean up iframes on rerun
browser: Support @testing-library/vue in browser mode out of the box
browser: Print correct transformed module graph
browser: Use
previewprovider when running in StackBlitzbrowser: Specify entries for correct deps optimization
browser: Allow iframe to load even if there is a custom CSP header
browser: Don't optimize Vitest dependencies
browser: Set server.open to false and move error handling after init
browser: Show correct prepare time
browser: Resolve
coverage.reporterfrom string valuesbrowser: Correctly update inline snapshot if changed
browser: Remove "util" warning
browser: Remove hacky retry
browser: Make userEvent more stable when running in parallel
browser: Print screenshot path alongside the test error message
browser: Print correct stack trace in source files
browser: Correctly mock optimized cjs dependencies
browser: Support shadow root and svg elements
coverage: Clean up empty coverage reports directory
coverage:
thresholds.autoUpdateto supportmergeConfigcoverage: Pass thresholds errors to
stderrofstartVitest()coverage: Exclude bench files from coverage
coverage: Vite to ignore dynamic import of provider
coverage: Istanbul to support import attributes
coverage: Remove work-around for implicit
elsedeps: Update vulnerable
test-excludeto v7expect: Fix immutable.js iterable equality
forks: Resolve
poolOptions.<name>.isolatefromforksoptionsrunner: Ensure inner suite { sequential: true } correctly overrides outer suite { concurrent: true }
runner: Ensure test.each print -0 and -NaN properly
snapshot: Fix
toMatchFileSnapshotwith empty filespy: Correctly track constructor's "this" type
types: Mark pool options as not available in project config
ui: Show correct module graph and project name in a Vitest workspace
ui: Update running todo tests inside todo suites (each)
ui:
FileDetailstitle status icon not being updatedui, browser: Disable mouse events when resizing main navigation panel
utils: Produce valid snapshot names
utils: Fix color util maximum call stack error
utils: Package exports
vite-node: Expose all envs from .env file, not just with a prefix
VITE_vitest: Expose
provideto the public APIvitest: Cache fs code only for forks pool
vitest: Allow testing unandled rejection/exception
vitest: Show all failed tests when rerunning a test