@vitest/spy
5.0.5 · 15 Oct 2026MIT202.7M / weekRepositoryHomepagenpmAtom feed
2.1.9 is the newest release of 2.x.
In short
4 breaking17 new33 fixed
- 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.
Release note
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 page object 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