@vitest/spy
5.0.5 · 15 Oct 2026MIT202.7M / weekRepositoryHomepagenpmAtom feed
138 stable releases, newest first, by release line. Notes are quoted as the maintainers published them.
- 3.x
3.1.0
31 Mar 2025Introduce
%$option to add number of the test to its titleAdd
diff.maxDepthoption and set non-Infinityvalue as a default to reduce crashAllow array element for
test.each/fortitle formatting
Features
Introduce
%$option to add number of the test to its titleAdd
diff.maxDepthoption and set non-Infinityvalue as a default to reduce crashAllow array element for
test.each/fortitle formattingAdd "configureVitest" plugin hook
Support
--configLoaderCLI optionAdded
vitest-browser-littovitest init browserand docsUse providers request interception for module mocking
browser: Introduce
and,orandfilterlocatorsreporter: Always render test time
reporter:
--silent=passed-onlyto log failed tasks onlyrunner: Add
test.scopedto overridetest.extendfixtures per-suitevitest: Allow conditional
context.skip(boolean)vitest: Support rolldown-vite in NormalizeUrlPlugin
Bug Fixes
Update test stats regularly
Fix vm tests flakiness
Set
diff.expand: falseas defaultbrowser: Correctly calculate timeout in hooks when actions are performed
deps: Update all non-major dependencies
reporter:
--hideSkippedTestsshould hide suites tooreporter: Report tests in correct order
reporter: Print test only once in the verbose mode
snapshot: Fix indent normalization
snapshot: This change can cause small amount of very old snapshots to be updated, but there will be no functional change to how they work.
Performance
browser: Fork jest-dom instead of bundling it
3.0.9
17 Mar 2025Typings of
ctx.skip()asneverCleanup vitest in public
resolveConfigAPIFix
toHaveBeenCalledWith(asymmetricMatcher)withundefinedarguments
Bug Fixes
Typings of
ctx.skip()asneverCleanup vitest in public
resolveConfigAPIFix
toHaveBeenCalledWith(asymmetricMatcher)withundefinedargumentsRace condition in RPC filesystem cache.
Fix
getState().testPathduring collection with no isolationSupport custom toString method in %s format
browser: Fail playwright timeouts earlier than a test timeout
browser: Remove @testing-library/dom from dependencies #7555)"
coverage: Browser mode +
coverage.allrunner: Show stacktrace on hook timeout error
vite-node: Fix source map of inlined node_modules
vite-node: Fix missing
buildStartweb-worker: Ensure
removeEventListeneris bound to worker
3.0.8
6 Mar 2025Fix fetch cache multiple writes
Use browser.isolate instead of config.isolate
Remove vestigial spy stub, import directly from
@vitest/spy
Bug Fixes
Fix fetch cache multiple writes
Use browser.isolate instead of config.isolate
Remove vestigial spy stub, import directly from
@vitest/spyCorrectly split the argv string
browser: Remove @testing-library/dom from dependencies
browser: Improve source map handling for bundled files
browser: Print related test file and potential test in unhandled errors
runner: Fix
beforeEach/Allcleanup callback timeoutrunner: Fix and simplify
Task.suiteinitializationsnapshot: Allow inline snapshot calls on same location with same snapshot
vite-node: Fix
buildStarton Vite 6
3.0.7
24 Feb 2025browser: Support webdriverio 9
deps: Update all non-major dependencies - in #7543
expect: Correct generic MatchersObject this type in expect.extend
Bug Fixes
browser: Support webdriverio 9
deps: Update all non-major dependencies - in #7543
expect: Correct generic MatchersObject this type in expect.extend
mocker: Include more modules to prefix-only module list
spy: Clear/reset/restore mocks in stack order
Performance
browser: Do wdio context switching only once per file
3.0.6
18 Feb 2025Fix
getMockedSystemTimeforuseFakeTimerCompat for jest-image-snapshot
Ensure project names are readable in dark terminals
Bug Fixes
Fix
getMockedSystemTimeforuseFakeTimerCompat for jest-image-snapshot
Ensure project names are readable in dark terminals
Exclude
queueMicrotaskfrom default fake timers to not break node fetchUse
tinyglobbyinstead offast-globbrowser: Fix mocking modules out of root
browser: Fix
toHaveClasstypingbrowser: Relax locator selectors methods
browser: Resolve thread count from
maxWorkersbrowser: Cleanup timeout on resolve and give more information in the error
coverage:
vite-nodeto pass correct execution wrapper offsetcoverage: Preserve moduleExecutionInfo in non-isolated runs
deps: Update all non-major dependencies
deps: Update all non-major dependencies
init: Invalid browser config
reporters: Render tasks in tree when in TTY
vite-node: Remove fake first line mapping on Vite 6
watch: Properly remove cache after removing existing test files
workspace: Forward
inspectrelated cli options
3.0.5
3 Feb 2025ui: Insert message "no tests found" in ui
Validate websocket request
This release includes security patches for:
Features
ui: Insert message "no tests found" in ui
Bug Fixes
Validate websocket request
Don't toggle cli cursor on non-TTY
vite-node: Differentiate file url with hash and query
3.0.4
23 Jan 2025Filter projects eagerly during config resolution
Apply
development|productioncondition on Vites 6
This release includes security patches for:
Bug Fixes
Filter projects eagerly during config resolution
Apply
development|productioncondition on Vites 6browser: Restrict served files from
/__screenshot-errordeps: Update all non-major dependencies
runner: Timeout long sync hook
typechecking: Support typechecking parsing with Vite 6
types: Fix public types
3.0.3
21 Jan 2025browser: Don't throw a validation error if v8 coverage is used with filtered instances
browser: Don't fail when running --browser.headless if the browser projest is part of the workspace
reporters: Update summary only when needed
3.0.2
17 Jan 2025Don't await an empty timeout after every test
expect: Fix
expect().resolves/rejectschain typings
3.0.0
16 Jan 2025- breaking
spy.mockResetchanges - breaking
Pass down context to test hooks
- breaking
Support Vite 6
Vitest 3 is here! There are a few breaking changes, but we expect the migration to be smooth. 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
spy.mockResetchanges - breaking
Pass down context to test hooks
- breaking
Support Vite 6
- breaking
coverage: Always exclude test files
- breaking
deps: Update fake-timers to v14.0.0
- breaking
expect: Check more properties for error equality
- breaking
runner: Support
describe(..., { shuffle: boolean })and inherit from parent suite - breaking
snapshot: Reset snapshot state for
retryandrepeats - breaking
spy: SpyOn reuses mock if method is already spyed on
- breaking
vitest: Don't expose default toFake config
Features
Support inline
diffoptions and supportprintBasicPrototypeAllow a custom note when calling
ctx.skip()dynamicallyAllow inline workspace configuration
Provide the current project to the global setup
Print project name as a label
Print a deprecation warning if suite or test uses object as the third argument
Expose versions from
vitest/nodeentry point and statically on Vitestdiff.printBasicPrototype: falseby defaultPrepare the Vitest API to be stable
Support Vite v6 in mocker package
Allow multi-browser configuration
Add resolved project names to the reporter API
Introduce the new reporter API
Add
describe.forapi: Add onBrowserInit event
browser: Support
actionTimeoutas playwright provider optionsbrowser: Support clipboard api
userEvent.copy, cut, pastebrowser: Implement locator.nth()
cli: Support excluding projects with
--project=!patterncli: Support specifying a line number when filtering tests
cli: Support location filters for suites
coverage:
thresholdsto support maximum uncovered itemsexpect: Add
toHaveBeenCalledExactlyOnceWithexpect matcherexpect: Add
toHaveBeenCalledAfterandtoHaveBeenCalledBeforeutilityexpect: Add
toSatisfyasymmetric matcherexpect: Add
toBeOneOfmatcherreporter: Add support for function type to classname option in the junit reporter
reporters:
summaryoption forverboseanddefaultreportersrunner: Test context can inject values from the config's
providerunner: Add "queued" state
snapshot: Provide
configtoresolveSnapshotPathui: Allow run individual tests/suites from the UI
ui: Make clicking on a test in the UI open the report section and scroll to the test failure if applicable
ui: Allow hide/show node_modules in module graph tab
vitest: Include
coverageMapin json reportvitest: Add
onTestsRerunmethod to global setup context
Bug Fixes
Misc fix for vite 6 ecosystem ci
Respect
cacheDirwhen optimizer is enabledReset runningPromise after
finallyin case there is an error to avoid it getting stuckRevert support for Vite 6
Support Node 21
Don't use
Customtype internallyPersist cli filters as watch mode file filter
Don't use dim color for succeeded tests
Fix missing chai types
cancelCurrentRunawaitsrunningPromiseAdd Locator typings for nth, first and last.
Batch console logs by microtask
Allow
getMockImplementationto return "once" implementationcapturePrintErrorlogger duplicate event handlersAllow slots in vitest-browser-vue
Reset root workspace project on restart
Cleanup
vitest/reportersentrypointColors on
forkspoolExport
VitestRunnertype fromvitest/runnersReturn test fn result to runner
Re-apply default conditions if using vite 6 or later
Prevent infinite loop on prettyDOM calls
api: Don't report events during
vitest listbenchmark: Disable type testing while benchmarking
benchmark: Rewrite reporter without
log-updatebrowser: Improve source maps when
vi.mockis presentbrowser: Explain TypeScript support in docs and add asymmetric matchers to types
browser: Fix matchers.d.ts
browser: Fix user event state on preview provider
browser: Fix provider options types
browser: Only use locator.element on last expect.element attempt
browser: Use correct project when filtering
entriesin the browser modebrowser: Fix
console.timewith fake timersbrowser: Add instance validation to resolve coverage error
coverage: Exclude browser mode iframe results
coverage: Correct coverage when
isolate: falseis usedcoverage: Prevent crash when v8 incorrectly merges static_initializer's
deps: Update all non-major dependencies - in #7085
deps: Update all non-major dependencies - in #7116
diff: Truncate to avoid crash on diff large objects
junit: Fix testsuites time to be sum of all testsuite items
pretty-format: Support react 19
reporters: Write buffered stdout/stderr on process exit
reporters: Rewrite
dotreporter withoutlog-updatereporters: Check
--hideSkippedTestsin base reporterreporters: Show
retryandrepeatscountsrunner: Long synchronous tasks does not time out
runner: Mark tests of
describe.todoas'todo'snapshot: Fix "obsolete" message on snapshot update re-run
snapshot: Preserve white space of
toMatchFileSnapshotsnapshot: Fix obsoleteness check of
toMatchSnapshot("...")typecheck: Fix typecheck collect on Vite 6
typecheck: Use unique temp and tsbuildinfo file for each tsconfig file
typecheck: Fix error test case mapping for
@ts-expect-errortypes: Make parameters non-nullable for Playwright options
ui: Wrong module graph when generating html.meta.json.gz in browser mode
ui: Add errors and draft state (*) to the code editor
vite-node: Fix error stack on Windows
vite-node: Properly normalize file url import
vite-node: Fix mandatory node prefix
watch: Don't indicate exit when no matching files
workspace:
extends: truecorrectly inherits all root config properties
- 2.x
2.1.8
2 Dec 2024Support Node 21
2.1.7
2 Dec 2024Revert support for Vite 6
2.1.6
26 Nov 2024Support Vite 6
2.1.5
13 Nov 2024- removed
ui: Remove crossorigin attributes for same origin assets
dangerouslyIgnoreUnhandledErrorswithout base reporterCapture
unhandledRejectioneven when base reporter is not used
Bug Fixes
dangerouslyIgnoreUnhandledErrorswithout base reporterCapture
unhandledRejectioneven when base reporter is not usedDon't change the working directory when loading workspace projects
Remove
sequence.concurrentfrom theRuntimeConfigtypeStop the runner before restarting, restart on workspace config change
Don't rerun on Esc or Ctrl-C during watch filter
Print ssrTransform error
Throw an error and a warning if
.poll,.element,.rejects/.resolves, andlocator.*weren't awaitedbrowser: Don't process the default css styles
browser: Support non US key input
browser: Stop the browser rpc when the pool is closed
browser: Init browsers eagerly when tests are running
coverage: Report uncovered files when re-run by
enteror'a'- removed
ui: Remove crossorigin attributes for same origin assets
vite-node: Improve esm check to decide external
vite-node: Top-level throw in module is not reported properly
vitest: Use fetch() implementation from happy-dom
Performance
Limit workspace project concurrency to available cores
2.1.4
28 Oct 2024browser: Allow custom HTML path, respect plugins
transformIndexHtmlwindows: Don't normalize drive case letter in root
browser: Fix default browser port
Features
This patch release includes a non-breaking feature for the experimental Browser Mode that doesn't follow SemVer. If you want to avoid picking up releases like this, make sure to pin the Vitest version in your
package.json. See npm's documentation about semver for more information.browser: Allow custom HTML path, respect plugins
transformIndexHtml
Bug Fixes
windows: Don't normalize drive case letter in root
browser: Fix default browser port
browser: Optimize expect-type
browser: Don't polyfill process.env
browser: Increment browser port automatically if there are several projects with browser.enabled
browser: Cleanup keyboard state
browser: Don't add
v=queries to setup files importsbrowser: User event cleanup on retry
browser: Ignore non mocked msw requests
browser: Initiate MSW in the same frame as tests
expect: Correct behavior of
toThrowErrorwith empty string parametermocker: Remove spy from peer dependencies
vitest: Print warnings form Vite plugins
vitest: Don't fail if the working directory starts with a lowercase drive letter
vitest: Silence import analysis warning
vitest,runner: Simplify
test.extendtype exports
Performance
Use
hashto replacecreateHash
2.1.3
14 Oct 2024- deprecated
vitest: Deprecate UserConfig in favor of ViteUserConfig
- deprecated
vitest: Deprecate old task types and node-reliant types
Fix error diff of
toBeNaN, toBeUndefined, toBeNull, toBeTruthy, toBeFalsy
Bug Fixes
Fix error diff of
toBeNaN, toBeUndefined, toBeNull, toBeTruthy, toBeFalsybrowser: Provide aria role intellisense
browser: Not.toBeInTheDocument works with locators API
browser: Use
/mockServiceWorker.jsinstead of/__vitest_msw__browser: Don't override the esbuild option in the browser mode
expect: Preserve prototype in
toMatchObjectdiffmocker: Specify correct spy dependency
runner: Ensure sequential suite overrides sequence.concurrent
- deprecated
vitest: Deprecate UserConfig in favor of ViteUserConfig
vitest: Don't hang with maxConcurrency 0
- deprecated
vitest: Deprecate old task types and node-reliant types
vitest: Fix
<empty line>logs when interleavingconsole.log/errorvitest: Show rollup error details as test error
vitest: Always inline setup files
vitest: Use
fast-globinstead oftinyglobbyin Vitestweb-worker: Share mocker with main executor
Performance
Reuse full name in reported tasks, update generator types
2.1.2
2 Oct 2024Move
Vitest.setServerto postconfigureServerhook to enable import analysis for workspace config loadingbenchmark: Clear
BenchmarkResult.samplesarray to reduce memory usagebrowser: Fix dynamic import inside worker
Bug Fixes
Move
Vitest.setServerto postconfigureServerhook to enable import analysis for workspace config loadingbenchmark: Clear
BenchmarkResult.samplesarray to reduce memory usagebrowser: Fix dynamic import inside worker
browser: Fix browser mock factory event race condition
browser: Serve ui assets as static
browser: Update solidjs testing library lib
browser: Use
data:protocol on preview provider file uploadbrowser: Fix base for client script
browser: Throw an error if "@vitest/browser/context" is imported outside of the browser mode
coverage: Remove empty coverage folder on test failure too
coverage: Include
*.astroby defaultcoverage:
cleanOnRerun: falseto invalidate previous resultsexpect: Fix
toBeDefinedwithexpect.pollforks: Fix
--cpu-profand--heap-profnot working by defaultrunner: Mark tests as skipped when
beforeAllfailedrunner: Support fixture parsing of lowered async syntax
runner: Fix fixture parsing of lowered async syntax for non arrow functions
runner: Guard test hook callback
runner: Run
onTestFinishedandonTestFailedduringretryandrepeatsui: List tests on ui when
--standalonevite-node: Fix esm false-detection inside comment
vitest: Install dependencies with the same version when prompted
vitest: Make env.SSR consistent between different pools
vitest: Don't start a websocket server if api is disabled
workspace: Fix glob pattern detection
workspace: Ignore DS_Store by default
2.1.1
13 Sep 2024browser: Make example test callbacks async
browser: Optimize vitest-browser-vue correctly
workspace: Resolve glob pattern once to avoid name collision
2.1.0
12 Sep 2024- breaking
workspace: Correctly resolve workspace globs and file paths
- breaking
workspace: This changes how the custom glob pattern in the workspace config is treated. Any file matching the glob is considered a Vitest config file. Any folder matching the glob pattern is treated as a workspace project and is subject to the regular config resolution (single
vitest.config.tsorvite.config.tsinside the folder) - breaking
workspace: For example,
projects/*will match anything inside theprojectsfolder. If it's a folder, we try to find the config inside that folder (if there is none, it is still treated as a project with the default config). If it's a file, it will be treated as a Vitest config.projects/**/*previously would assume that you only wanted to have folders as projects, but now it will match every single file insideprojects.
This release makes another big change to the Browser Mode by introducing locators API:
test('renders blog posts', async () => { const screen = page.render(<Blog />) await expect.element(screen.getByRole('heading', { name: 'Blog' })).toBeInTheDocument() const [firstPost] = screen.getByRole('listitem').all() await firstPost.getByRole('button', { name: 'Delete' }).click() expect(screen.getByRole('listitem').all()).toHaveLength(3) })You can use either vitest-browser-vue, vitest-browser-svelte or vitest-browser-react to render components and make assertions using locators. Locators are also available on the
pageobject from@vitest/browser/context.Potential Breaking Change
- breaking
workspace: Correctly resolve workspace globs and file paths
- breaking
workspace: This changes how the custom glob pattern in the workspace config is treated. Any file matching the glob is considered a Vitest config file. Any folder matching the glob pattern is treated as a workspace project and is subject to the regular config resolution (single
vitest.config.tsorvite.config.tsinside the folder) - breaking
workspace: For example,
projects/*will match anything inside theprojectsfolder. If it's a folder, we try to find the config inside that folder (if there is none, it is still treated as a project with the default config). If it's a file, it will be treated as a Vitest config.projects/**/*previously would assume that you only wanted to have folders as projects, but now it will match every single file insideprojects. - breaking
workspace: This change doesn't affect non-glob usage.
Features
api: Make spec into a class instead of a tuple
browser: Move page.config to server.config, add more docs
browser: Make iframe scalable, improve documentation
browser: Introduce built-in locators
browser: Support v8 coverage
browser: Support
userEvent.uploadin playwright providerbrowser: Support
--inspectbrowser: Support
--inspect-brkcli: Extend existing list command to output only a list of file names
coverage: Add
--exclude-after-remapmocker: Introduce @vitest/mocker package, allow
{ spy: true }instead of a factoryvitest: Add "provide" option
vitest: Add return type and promisable mockFactory
vitest: Add
vi.advanceTimersToNextFramevitest: Allow env to be stubbed to undefined
Migrate from
fast-globtotinyglobby
Bug Fixes
Correctly resolve nested mocks with
indexfileDon't panic when coverage.reporter is a string
Align RawMatcherFn type definition with Jest
Cjs build of vite node server
Allow inlining vite's cached dependencies
Print unexpected error message if peer dependencies have a different version
Ignore importer when resolving Vitest
expect.getState().testPathalways returns correct pathUserEvent works consistently between providers
browser: Print correct stack trace for unhandled errors
browser: Use documentElement as the root for selector
browser: Keep querying elements even if locator is created with elementLocator, add pubic @vitest/browser/utils
browser: Produce valid config file if preview provider is used
browser: Correctly run in-source tests in the browser
browser: Exclude missed packages from optimization, print help message
browser: Define mocker as a dependency
coverage: Warn if
vitestand@vitest/*versions don't matchcoverage: V8 to support source maps with multiple sources
coverage: V8 to warn instead of crash when conversion fails
coverage: Use project specific
vitenodefor uncovered filesrunner: Use
performance.nowinstead ofDate.nowfor durationrunner: Async assertion auto await should timeout
snapshot: Reject multiple
toMatchInlineSnapshotupdates at the same locationsnapshot: Improve inline snapshot inside loop rejection
typecheck: Run both runtime and typecheck tests if
typecheck.includeoverlaps withincludetypes: Allow Callbacks Passed to before*/after* to Return Anything
ui: Remove "filters" flickering
ui: Render project name consistently
vite-node: Disable watcher if hmr is disabled
vite-node: Fix watch on vite 6
vitest: Update json reporter output
vitest: Add more type guards for --merge-reports
vitest: Always resolve vitest to the root version
vitest: Dispose vmForks listeners to avoid memory leak
2.0.5
31 Jul 2024Introduce experimental reported tasks
Show a difference between string characters if both values are strings
testNamePatternadds leading space
Features
Introduce experimental reported tasks
This is part of the experimental API and doesn't follow semver. We are hoping to stabilize it for 2.1. If you are working with custom reporters, give this a go!
Bug Fixes
Show a difference between string characters if both values are strings
testNamePatternadds leading spacebrowser: Don't bundle
afterEachcleanup hooks in node entrypointbrowser: UserEvent.setup initiates a separate state for userEvent instance
browser: Correctly import optimized module in vi.importActual
browser: Passing options to hover/unhover
browser: Improve unique CSS selector generation
vitest: Remove nuxt from auto inline deps
vitest: Improve
defineProjectanddefineWorkspacetypesvitest: Correctly resolve mocked
node:*imports in__mocks__folderweb-worker: Expose globals on self
2.0.4
22 Jul 2024One-line environment options
Resolve assets imported with
requirebrowser: Don't panic if @vitest/browser is installed outside of project root
Bug Fixes
One-line environment options
Resolve assets imported with
requirebrowser: Don't panic if @vitest/browser is installed outside of project root
browser: Set global filepath
browser: Allow preview and open in the editor screenshot error from ui
coverage: Global thresholds to include files from glob thresholds
coverage: Consistent type-only file handling
coverage: Ignore
*.ctsfilescoverage: Add
thresholds.<glob>.100optionspy: Fix
mockImplementationfor function overload and unions
2.0.3
15 Jul 2024ui: Show all suites/tests when parent matches
--inspect-brkstop on Windowsbrowser: Don't import from "vite"
Features
ui: Show all suites/tests when parent matches
Bug Fixes
--inspect-brkstop on Windowsbrowser: Don't import from "vite"
browser: Allow immidiate reinvalidation of mocked dependencies
spy: Fix type error when assigning
vi.spyOntoMockInstanceof function overloadvite-node: Remove suffix slash on file protocol for window
2.0.2
10 Jul 2024browser: Remove @vitest/runner > pretty-format from prebundling because it doesn't exist
browser: Inline pretty-format and replace picocolors with tinyrainbow
browser: Remove
crypto.randomUUIDfrom the client
Bug Fixes
browser: Remove @vitest/runner > pretty-format from prebundling because it doesn't exist
browser: Inline pretty-format and replace picocolors with tinyrainbow
browser: Remove
crypto.randomUUIDfrom the clientbrowser: Correctly overwrite loupe require
browser: Dedupe @vitest/browser/client
browser: Don't release keyboard automatically
ui: Test files notified only when running
ui: Encode html entities in task name
web-worker: Peer dependency version on
vitest
Performance
browser: Don't import msw if no modules are mocked
2.0.1
8 Jul 2024browser: Correctly inherit browser config in a workspace
ui: Move virtual scroller to dev dependencies
vitest: Print only running files, not every file
2.0.0
8 Jul 2024- breaking
Simplify mock function generic types and align with jest - by @hi-ogawa
- breaking
Remove
--segfault-retry - breaking
Run suite hooks in a stack
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
- 1.x
1.6.1
3 Feb 2025Reading the note…
1.6.0
3 May 2024Support standalone mode
Custom "snapshotEnvironment" option
benchmark: Support comparing benchmark result
Features
Support standalone mode
Custom "snapshotEnvironment" option
benchmark: Support comparing benchmark result
browser: Allow injecting scripts
reporter: Support
includeConsoleOutputandaddFileAttributein junitui: Sort items by file name
Bug Fixes
Keep order of arguments for .each in custom task collectors
Call
resolveId('vitest')afterbuildStartHash the name of the file when caching
Don't panic on empty files in node_modules
Use
toJSONfor error serializationcoverage: Exclude
*.test-d.*by defaultcoverage: Apply
vite-node's wrapper only to executed filesvm: Support network imports
Performance
Improve performance of forks pool
Unnecessary rpc call when coverage is disabled
1.5.3
30 Apr 2024Reading the note…
1.5.2
25 Apr 2024Reading the note…
1.5.1
24 Apr 2024Reading the note…
1.5.0
11 Apr 2024Add configuration for diff truncation
Remove unrelated noise from diff for toMatchObject()
Allow custom host for --inspect and --inspect-brk
Features
Add configuration for diff truncation
Remove unrelated noise from diff for toMatchObject()
Allow custom host for --inspect and --inspect-brk
coverage: V8 to ignore empty lines, comments, types
Bug Fixes
describecalls not taking generic type parametersPrevent hang when
processis mockedDon't check for "node:internal/console/" in console interceptor in case the environment is not Node.js
The value received by toMatch should be a string
Increase stack trace limit for location, don't hardcode suite position
benchmark: Run benchmark suites sequentially
benchmark: Fix benchmark summary of single bench suite
benchmark: Table reporter for non TTY output
expect: Fix
toHaveBeenNthCalledWitherror message when not calledtypes: Pass correct type for suite factory
utils: Fix object diff with getter only property
vite-node: Fix
isValidNodeImportto check"type": "module"firstvitest: Correctly send console events when state changes
vitest: Initiate FakeTimers on demand
vitest: Check unhighlighted code for code frame line limit
vitest: Correctly filter by parent folder
vitest: Close inspector immediately if run is canceled
workspace: Set CWD to config directory, allow overriding local .env
1.4.0
15 Mar 2024- deprecated
config: Deprecate
cache.diroption Throw error when using snapshot assertion with
notAdd a flag to include test location in tasks
Features
Throw error when using snapshot assertion with
notAdd a flag to include test location in tasks
cli: Support wildcards in
--projectoptionconfig: Add
shuffle.filesandshuffle.testsoptions- deprecated
config: Deprecate
cache.diroption coverage: Support
--changedoptionvitest: Support
clearScreencli flag
Bug Fixes
Repeatable
--projectoption--inspect-brkto pause before executionCorrect locations in test.each tasks
api: Use resolvedUrls from devserver
browser: Add
magic-stringtooptimizeDeps.includecoverage: Expensive regexp hangs v8 report generation
coverage: V8 to ignore type-only files
coverage: Respect source maps of pre-transpiled sources
coverage: Prevent
reportsDirectoryfrom removing user's projectexpect: Show diff on
toContain/toMatchassertion errorforks: Wrap
definesto supportundefinedvaluestypecheck: Update get-tsconfig 4.7.3 to fix false circularity error
ui: Escape html in error diff
vitest: Loosen
onConsoleLogreturn typevitest: Ensure restoring terminal cursor on close
vitest: Ignore timeout on websocket reporter rpc
vitest: Correctly override api with --no-api flag
vitest: Logs in
beforeAllandafterAllworkspace: Throw error when browser mode and
@vitest/coverage-v8are used
1.3.1
20 Feb 2024Reading the note…
1.3.0
16 Feb 2024- deprecated
Deprecate watchExclude
browser: Run test files in isolated iframes
config: Add
snapshotSerializersoption
Features
- deprecated
Deprecate watchExclude
browser: Run test files in isolated iframes
config: Add
snapshotSerializersoptionreporters: Support custom options
runner: Support automatic fixtures
ui: Save splitpanes size to local storage
vitest: Add onTestFinished hook
vitest: Add github actions reporter
vitest: Expose jsdom global if jsdom environment is enabled
vitest: Add new CLI options
vitest: "test" accepts options object as the second parameter
vm: Support wasm module
Bug Fixes
Fix sourcemap in vm pools
Don't optimize react/jsx-runtime by default when running in Node
Rpc timeout error messages to include caller
Requires fixed version across the monorepo
Prevent merging of
poolOptionsbrowser: Don't exclude node builtins from optimization
browser: Support
coverage.reportsDirectorywith multiple directoriescli: Parse
--browser=<name>correctlycoverage:
.tmpdirectory conflicts with--shardoptionreporters: Testsuite name should include project root in Junit output
typecheck: Fix suite collection while-loop
ui: Fix tests duration time
utils: Fix asymmetric matcher diff inside array
vitest: Correctly report failed test files as failures in json reporter, export json reporter types
vitest: Don't run typecheck tests in browser if both are enabled
vitest: Handle function config inside
defineWorkspacevitest: Remove excessive listeners when running without isolation, don't reset the state
vitest: Auto-enable "github-actions" only where users didn't configure reporters
vitest: Support more array cli options
vitest: Add types for the new global
jsdomvariablevitest: Expose onTestFinished globally
vitest: Disable optimizer by default until it's stable
vitest: Delegate snapshot options to workspace from root config
vitest: Fix
optimizeDeps.disabledwarnings on Vite 5.1vm: Handle
disableConsoleInterceptconfigvm: Improve error when module is not found
1.2.2
26 Jan 2024Reading the note…
1.2.1
17 Jan 2024Reading the note…
1.2.0
12 Jan 2024Support case-insensitive path matching in cli
Add typeahead search
Add syntax highlighting to error messages
Features
Support case-insensitive path matching in cli
Add typeahead search
Add syntax highlighting to error messages
Allow extending toEqual
coverage: Custom reporter support
ui: Show unhandled errors on the ui
vitest: Add
--disable-console-interceptoption to allow opting-out from automatic console log interceptionvitest: Allow overiding package installer with public API
Bug Fixes
browser: Support vite config
server.headersbrowser: Fix
testNamePatternconfigbrowser: Fix updating snapshot during watch mode
browser: Remove redundant test failure logging
happy-dom: Window.close() for environment teardown
utils: Fix
objDisplaydefault truncate option fortest.eachtitlevitest: Fix tap reporter to handle custom error
vitest: Gracefully exit Vitest if
process.exitis called inside the testvitest: Throw "cannot mock" error only in isolated pools
vitest: Don't throw SyntaxError when "await vi.hoisted" is used
vitest: Correctly parse --maxWorkers/--minWorkers
vitest: Show correct error when vi.hoisted is used inside vi.mock and the other way around
vitest: Call global teardown when using workspaces
vitest: Use file instead of id for HMR
vitest: Add inlined deps to ssr.noExternal so they are added to the module graph
workspace: Support overring
poolandpoolOptionson project level
1.1.3
5 Jan 2024Reading the note…
1.1.2
4 Jan 2024Reading the note…
1.1.1
31 Dec 2023Reading the note…
1.1.0
19 Dec 2023Add es-main compatibility to vite-node
Add
--workspaceoption, fix root resolution in workspacesAdd
--no-file-parallelism,--maxWorkers,--minWorkersflags
Features
Add es-main compatibility to vite-node
Add
--workspaceoption, fix root resolution in workspacesAdd
--no-file-parallelism,--maxWorkers,--minWorkersflagsAdd
--no-isolateflag to improve performance, add documentation about performanceAdd
--excludeCLI flag
Bug Fixes
Correctly reset provided values
expect: Fix
toHavePropertyassertion error diffrunner: Handle fixture teardown error
types:
defineWorkspacefix intellisense and report type errorsui: Escape html for console log view
ui: Fix coverage iframe url for html report preview
ui: Show file item when search filter matches only test cases
vitest: Pass down CLI options to override workspace configs
1.0.4
9 Dec 2023Reading the note…
1.0.3
9 Dec 2023Reading the note…
1.0.2
7 Dec 2023Reading the note…
1.0.1
4 Dec 2023Reading the note…
1.0.0
4 Dec 2023- breaking
Add support for
poolandpoolOptions, remove old flags - breaking
Support multiple parallel
child_process - breaking
Make snapshots more visually pleasing
Vitest 1.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
Add support for
poolandpoolOptions, remove old flags - breaking
Support multiple parallel
child_process - breaking
Make snapshots more visually pleasing
- breaking
Set
vitestpeer dependency range for sub packages - breaking
Bump minimum node version to 18 and match Vite 5 requirement
- breaking
Remove deprecated node loader
- breaking
Move browser providers to @vitest/browser package
- breaking
Remove EnhancedSpy type, deprecate SpyInstance, improve mocks and vi documentation
- breaking
expect().toContain()can handle classList, Node.contains, and any array-like structure. This means you cannot use it to check if one object is a subset of another - useexpect().toMatchObject()in that case - breaking
runner: Correctly process custom tasks, update runner hooks naming
- breaking
coverage: glob based coverage thresholds
- breaking
coverage: Use
transformModeand workspace project based source maps - breaking
coverage: Enable
coverage.allby default
Features
Add Marko example and include code coverage for Marko files
Update magic-string
Implement provide/inject API to transfer data from the main thread
Improve expectTypeOf error messages
Add test.sequential() api
Allow custom pools
Add --project option to limit what projects are running
benchmark: Move importTinybench to runner
browser: Support "none" provider and update lit example to use it
coverage: Support
/* v8 ignore...ignore hintsexpect: Support
expect.closeToapiexpect: Compare URL objects by href
snapshot: Add option to configure snapshot directory
vite-node: Support import.meta.hot.off for vite 5
vitest: Expose getBenchFn, getBenchOptions
vitest: Run typecheck during tests
vitest: Filter stacktraces
vitest: Expose execArgv to the different pools
Bug Fixes
Add multiple globals in VM+JSDOM
Ignore "plugins" field in snapshotFormat option
nextTickmocking error message to mention correct config optionExport VitestUtils interface
Assertion diff message handle non-writable sub-properties
Don't bundle import from rollup
Support accessing fixture at same index of dependency fixture
Make asynchronous fixtures work concurrently
Coverage.100 crash when using as an cli argument
Support typechecking with Yarn PnP
Support accessing task from test context without accessing fixtures
Copy custom asymmetric matchers to local
expectApply serializer to
Errorinstance for thrown snapshotThrow an error when running "vitest typecheck"
Don't expand snapshot diff by default
Handle errors thrown in fixtures
Default --open to !process.env.CI
Disable ESBuild when user config disables it
Inherit concurrent/sequential in nested suites
Provide customTesters to asymmetric matchers
Apply
retryandbailfrom test config fileRespect trailing slash when filtering by file path
Date prototype when using setSystemTime
BrowserTestRunner called incorrect super methods
Set process name for idle workers
browser: Improve error handling and don't rely on Node.js builtin modules in browser mode
browser: Disable hijacking ES modules until vi.mock is implemented
browser: Add vitest/ imports to entries
browser: Wait until vite finishes prebundling of vitest dependencies
browser: Allow for
pretty-formatas a sibling dependencybrowser: Don't go into an infinite reload loop, don't fail if "error" event is caught
browser: Respect "server" option in vite config
cli: Do not capture
stdinwhen in run modeconfig: Type issue of
poolandpoolMatchGlobsin defineConfigcoverage:
thresholdAutoUpdateto detect zero limitscoverage: Exclude files and directories starting with dot by default
coverage: Improve memory usage by writing temporary files on file system
expect: Publish types file
expect:
Object.freezebreakstoEqualexpect: Publish semantically correct chai types
expect: Print full error if promise is rejected
expect: Don't fail when using jest expect
happy-dom: Don't crash when calling useFakeTimers with empty config
jsdom: Don't go into an infinite recusion when calling atob
runner: Fixture needs to be initialized for each test
runner: Nested tests should throw errors
- removed
runner: Removes deprecated
erroroption from TaskResult runner: Preserve fixtures when calling runif and skipif
runner: PassWithNoTests option not work
vite-node: Have a separate cache for web/ssr transforms
vite-node: Mjs files watch not work
vitest: Make @types/node optional
vitest: Inline chai types instead of using @types/chai
vitest: Don't initialize globalSetup if workspace doesn't run tests
vitest: Deduplicate vitest when running globally or in a workspace
vitest: Print file path instead of "unknown test" when logging
vitest: Failed to load custom environment from js/ts file
vitest: Support assets in new URL in Vite 5
vitest: Correctly hoist
vi.hoistedif assignedvitest: Run globalSetup from the root config even if it's not in a workspace
vitest: Pass correct mode in vitest config function
vitest: Throw an error if vitest is imported using require()
vitest: Use correct type for defineProject to allow usage in mergeConfig
vitest: Throw an error if Vite wasn't able to resolve aliased path
vitest: Improve vi.waitUntil type to excude falsy types
vitest: Add import-meta.d.ts
vitest: Correctly support CSS variable when using happy-dom
vitest: Pass correct server options in workspace
vitest: Independently mock each instance's methods for mocked class
vm: Remove sequencer usage from createVmThreadsPool function
Performance
Update
log-updatev9Close pool early in run-mode
coverage-istanbul:
all: trueinstruments already instrumented files
- 0.34.x
0.34.7
2 Oct 2023Reading the note…
0.34.6
29 Sep 2023Reading the note…