@vitest/expect
5.0.5 · 15 Oct 2026MIT151.9M / weekRepositoryHomepagenpmAtom feed
4.1.12 is the newest release of 4.x.
In short
29 breaking1 removed32 new12 faster69 fixed1 internal
- breaking
Remove
'basic'reporter - breaking
Simplify default exclude pattern
- breaking
Remove deprecated getSourceMap
- breaking
Replace deprecated ErrorWithDiff with TestError
- breaking
Remove UserConfig type in favor of ViteUserConfig
- breaking
Remove deprecated coverage options in favor of
vitest/nodeexports - breaking
Remove deprecated internal helpers and environment exports
- breaking
Remove deprecated typecheck and runner types
Release note
Vitest 4.0 is out!
To stay updated, read our blog post and check the migration guide.
Breaking Changes
- breaking
Remove
'basic'reporter - breaking
Simplify default exclude pattern
- breaking
Remove deprecated getSourceMap
- breaking
Replace deprecated ErrorWithDiff with TestError
- breaking
Remove UserConfig type in favor of ViteUserConfig
- breaking
Remove deprecated coverage options in favor of
vitest/nodeexports - breaking
Remove deprecated internal helpers and environment exports
- breaking
Remove deprecated typecheck and runner types
- breaking
Remove Node types from the main entry point, use
vitest/nodeinstead - breaking
Remove support for Vite 5
- breaking
Remove deprecated types
- breaking
Remove deprecated environmentMatchGlobs and poolMatchGlobs
- breaking
Remove deprecated
workspaceoption in favor ofprojects - breaking
Ignore
--standalonewhen CLI filename filter is used - breaking
Use module-runner instead of vite-node
- breaking
Rewrite spying implementation to make module mocking more intuitive
- breaking
Remove deprecated APIs
- breaking
Remove
minWorkersand set it automatically to 0 in non watch mode - breaking
Verbose reporter prints tests in a list, introduce
treereporter - breaking
Include shadow root contents in pretty-format output
- breaking
Remove deprecated order from test() API
- breaking
Rewrite pools without
tinypool - breaking
browser: Require a provider factory instead of a string
- breaking
expect: Pass current equality testers to asymmetric matcher
- breaking
projects: Allow only files that have "vitest.config" or "vite.config" in the name
- breaking
reporter: Remove deprecated APIs
- breaking
runner: Set mode to
todoif no function is passed down totestordescribe - breaking
snapshot: Fail test with obsolete snapshot on CI
- breaking
spy: Support spying on classes
Features
Provide entity to onConsoleLog
Add
onUnhandledErrorcallbackAdd spy option to vi.mockObject
Don't use vite-node in coverage packages
Clickable dashboard numbers
Display test "path" when filtering
Introduce separate packages for browser mode providers
Add hooks with type-safe extra context to TestAPI
Support
expect.assertfor type narrowingAdd
displayAnnotationsoption togithub-optionsAdd schema validation matchers
Add a way to dump transformed content
api: Expose
experimental_parseSpecificationsapi: Expose Vitest watcher
api: Add
enableCoverageanddisableCoveragemethodsapi: Add
getGlobalTestNamePatternmethodapi: Add
relativeModuleIdtoTestModuleapi: Add
getSeedmethodbrowser: Support
toBeInViewportutility method to assert element is in viewport or notbrowser: Add qwik to the
vitest initcli commandbrowser: Introduce
toMatchScreenshotfor Visual Regression Testingbrowser: Add
trackUnhandledErrorsoptionbrowser: Support iframe locator with playwright provider
browser: Add
lengthproperty to locators,toHaveLengthnow accepts locatorsbrowser: Support playwright tracing
browser: Expose
optionsonBrowserProviderOptionbrowser: Support
--inspectoption in webdriveriobrowser: Support custom screenshot comparison algorithms
coverage:
autoUpdateto support percentage formattingexpect: Support
toBeNullableexpect function to check provided value is nullishmocker: Add
automockerentry
Bug Fixes
Allow overriding globals in types
Remove unused dependencies
Distribute test files to shards more evenly
Use suite's timeout when
test.extendSupport snapshot with no object key sorting
Annotation location always points to the test file
Add
--changedflag support tovitest listcommandPrevent rpc timeout on slow thread blocking synchronous methods
Forbid setting environment to
browserInvalidate modules in all module graphs when the file is changed
Screenshot masks with Playwright provider
Configure
oxcinstead ofesbuildonrolldown-viteMake sure test errors always have
stacksproperty in Node.js contextSupport
import.meta.resolveon Vite 7Show the assertion error first when
expect.pollassertion failsOverride fake timers when
useFakeTimersis called multiple timesCustom expect messages for
expect.extendmatchersProcess sourcemaps for stack traces from
globalSetupfilesResolve performance issue when throwing errors with stackTraceLimit = 0
Avoid recursively applying
$and%formatting totest.for/eachtitleReplace wildcard exports
"./*"with specific files in vitest packageDon't publish unused d.ts files
Remove loupe dependencies from
optimizeDeps.includefor browser modeUpdate
enginesfield to drop Node 18 supportCorrectly inherit test options on extended tests
Update @types/node peer deps
Re-export CDP Session directly from playwright
Disable trackUnhandledErrors if inspector is enabled
baseoption doesn't crash vitestbrowser: Run in-source tests only when the file itsels is a test file
browser:
locator.element()returnsHTMLElementorSVGElementbrowser: Don't import from
vitedirectlybrowser: Update expect.element type to match the implementation
browser: Throw an error if iframe is not accessible anymore
browser: Stop creating unnecessary directories when taking screenshots
browser: Always define commands
browser: Exclude deprecated context import from optimization
browser: Allow importing BrowserCommand if no browser package is installed
browser: Define an export for browser/utils
browser: Allow service workers to mock the network in chromium without breaking vi.mock
browser: Support sync
not.toBeInTheDocument()core: Fix
objectContainingexpect utility to have more compatibility to jest's onecoverage: Include files based on
--projectfiltercoverage: Prevent encoding filenames of uncovered files
coverage: Handle query param based transforms correctly
coverage: Enforce order of
vitest:coverage-transformplugincoverage: V8 to ignore Vite's generated cjs import helpers
coverage: Keep only strings in
coverage.excludedeps: Update all non-major dependencies
deps: Update all non-major dependencies - in #8328
deps: Update all non-major dependencies - in #8348
deps: Update all non-major dependencies
deps: Update all non-major dependencies - in #8550
jsdom: Override globals that Fetch API relies on
jsdom: Support AbortSignal API
mocker: Fix
regexpHoistableto allow whitespace before parenthesesmodule-runner: Resolve
resolvedSourcescorrectlymodule-runner: Support getBuiltins
pool: Properly reuse the vm pool
reporter: Invisible CLI menus when
vitest --standalonerolldown-vite: Properly disable minifier in the browser client
runner: Don't bundle runner with utils
spy: Fix spyOn types with optional method
spy: Can respy on an exported method
spy: Don't fail when spying on static getters
types: Ensure Chai declaration merge works with TS-Go
types: Allow returning a promise from defineConfig
ui: Keep the same tab open when clicking on different tests
- removed
utils: Remove ast export
vitest: Override
config.includeoption withconfig.browser.instances.includeoption if it is specifiedwdio: Wait for the driver to be properly closed
wdio: Properly construct the shadow root selector if there are multiple elements
Performance
Avoid spawning extra workers if no tests will run there
Don't set
process.titleRemove chai as a direct dependency, keep it in
@vitest/expectReduce the amount of dynamic imports
Use ES2022 language features
Delay populating node-globals
Get
workerIdfrom a global objectReplace startsWith with strict equality
Reduce the number of unused imports
Use experimental
meta.resolveflag instead of a custom loaderCreate only one fetcher per project
pool: Resolve all environments first