@vitest/expect
5.0.5 · 15 Oct 2026MIT151.9M / weekRepositoryHomepagenpmAtom feed
4.1.12 is the newest release of 4.x.
In short
1 removed3 deprecated47 new1 faster78 fixed2 internal
- removed
browser: Remove
--remote-debugging-addressfrom chrome args - deprecated
Deprecate several vitest/* entry points
- deprecated
Deprecate unused types in matcher context
- deprecated
Deprecate
toBe*spy assertions in favor oftoHaveBeen*(andtoThrowError)
Release note
Vitest 4.1 is out!
This release page lists all changes made to the project during the 4.1 beta. To get a review of all the new features, read our blog post.
Features
Return a disposable from doMock()
Added chai style assertions
Update to sinon/fake-timers v15 and add
setTickModeto timer controlsExpose matcher types
Add
toTestSpecificationto reported tasksShow a warning if
vi.mockorvi.hoistedare declared outside of top level of the moduleTrack and display expectedly failed tests (.fails) in UI and CLI
Support tags
Implement
aroundEachandaroundAllhooksStabilize experimental features
Accept
neworallin--updateflagSupport
metain test optionsSupport type inference with a new
test.extendsyntaxSupport 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 listto statically collect tests instead of running files to collect themAdd
--detect-async-leaksImplement
mockThrowandmockThrowOnceSupport
update: "none"and add docs about snapshots behavior on CISupport playwright
launchOptionswithconnectOptionsAdd
page/locator.markAPI to enhance playwright traceapi: Support tests starting or ending with
testinexperimental_parseSpecificationapi: Add filters to
createSpecificationapi: Expose
runTestFilesas alternative torunTestSpecificationsapi: Add
allowWriteandallowExecoptions toapiapi: Allow passing down test cases to
toTestSpecificationbrowser: Add
userEvent.wheelAPIbrowser: Add
filterNodeoption to prettyDOM for filtering browser assertion error outputbrowser: Support playwright persistent context
browser: Added
detailsPanelPositionoption and buttonbrowser: Use BlazeDiff instead of pixelmatch
browser: Add
findElementand enable strict mode in webdriverio and previewcli: Add @bomb.sh/tab completions
coverage: Support
ignore start/stopignore hintscoverage: Add
coverage.changedoption to report only changed filesexperimental: Add
onModuleRunnerhook toworker.initexperimental: Option to disable the module runner
experimental: Add
importDurations: { limit, print }optionsexperimental: Add print and fail thresholds for
importDurationsfixtures: Pass down file context to
beforeAll/afterAllreporters: Add
agentreporter to reduce ai agent token usagerunner: Enhance
retryoptionsui: Allow run individual test/suites
ui: Add project filter/sort support
ui: Add duration sorting to explorer
vitest: Add run summary in GitHub Actions Reporter
Bug Fixes
- deprecated
Deprecate several vitest/* entry points
Use
meta.urlincreateRequirePreact browser mode init example of render function not async
- deprecated
Deprecate unused types in matcher context
Handle
external/noExternalduringconfigEnvironmenthookReplace default ssr environment runner with Vitest server module runner
Propagate experimental CLI options to child projects
Show a warning when
browser.isolateis usedFix
vi.mock({ spy: true })node v8 coverageDon't show internal ssr handler in errors
Close vitest if it failed to start
Fix ssr environment runner in project
Trim trailing white spaces in code block
Support inline snapshot inside test.for/each
Apply source maps for external module stack trace
Remove the
.namefrom statically collected testDon't suppress warnings on pnp
Support snapshot with
expect.softLog seed when only
sequence.shuffle.testsis enabledExternalize
expect/src/utilsfromvitestIgnore test.override during static collection
Increase stacktrace limit for
--detect-async-leaksHanging-reporter link in cli
Fix teardown timeout of
aroundEach/Allwhen inneraroundEach/AllthrowsFix ui mode / html reporter and coverage integration
Don't continue when
aroundEach/Allsetup timed outAlign
VitestRunnerConfigoptional fields withSerializedConfigHandle Symbol values in format utility
- deprecated
Deprecate
toBe*spy assertions in favor oftoHaveBeen*(andtoThrowError) Don't propagate nested
aroundEach/Allerrors but aggregate them on runnerShow a better error if there is a pending dynamic import
Preserve stack trace of
resolves/rejectschained assertion errorHandle module-sync condition in vmThreads/vmForks require
Hooks should respect
maxConcurrencyRecursively autospy module object
Remove trailing spaces from diff error log
Respect project
resolve.conditionsfor externalsUse object for WeakMap instead of a symbol to support webcontainers
Fix re-mocking virtual module
Cancelling should stop current test immediately
Make
mockObjectchange backwards compatibleFix
URL.nameon jsdomSave and restore module graph in blob reporter
Don't silence reporter errors from test runtime events handler in normal run and --merge-reports
Fix
vi.importActual()for virtual modulesThrow
FixtureAccessErrorif suite hook accesses undefined fixtureAllow hyphens in project config file name pattern
Manual and redirect mock shouldn't
loadortransformoriginal modulehideSkippedTestsshould not hidetest.todoAllow catch/finally for async assertion
Resolve fixture overrides from test's suite in
beforeEachhooksUse isAgent check, not just TTY, for watch mode
Use
performance.nowto measure test timeout durationCorrectly identify concurrent test during static analysis
browser: Avoid updating screenshots when
toMatchScreenshotpassesbrowser: Hide injected data-testid attributes
browser: Throw an error if iframe was reloaded
browser: Encode projectName in browser client URL
browser: Don't take failure screenshot if tests have artifacts created by
toMatchScreenshot- removed
browser: Remove
--remote-debugging-addressfrom chrome args browser: Make sure userEvent actions support
ensureAwaitedbrowser: Types of
getCDPSessionandcdp()browser: Skip esbuild.legalComments when using rolldown-vite
chai: Don't allow
deepEqualin the config because it's not serializablecoverage: Infer transform mode for uncovered files
coverage:
thresholds.autoUpdateto preserve ending whitespacedeps: Update all non-major dependencies
deps: Update all non-major dependencies - in #9485
deps: Update all non-major dependencies - in #9567
expect:
toMatchObject(Map/Set)should expectMap/Seton left hand sideexpect: Fix objectContaining with proxy
expect: Support arbitrary value equality for
toThrowand make Error detection robustmock: Inject helpers after hashbang if present
mocker: Update vite's peer dependency range
reporter:
dotreporter leaves pending testsrunner: Mark repeated tests as finished on last run
spy: Support deep partial in vi.mocked
spy: Fallback to object accessor if descriptor's value is
undefinedspy: Throw correct errors when shorthand methods are used on a class
types:
bench.reportersno longer gives type errors when passing file name string pathsui: Process artifact attachments when generating HTML reporter
ui: Don't fail if --ui and --root are specified together
Performance
pretty-format: Combine DOMElement plugins