@vitest/mocker
5.1.0 · 2 Nov 2026MIT190.8M / weekRepositoryHomepagenpmAtom feed
2.1.9 is the newest release of 2.x.
In short
2 new12 fixed
Security
2 advisories affect 2.1.0; 4.1.12 fixes them
- ModerateVitest: Code injection via unauthenticated manual mock registrationGHSA-qxg6-89mg-rqv8 · 21 Oct 2026Fixed in 4.1.12
- ModerateVitest: Path Traversal / Arbitrary File Read via @vitest/mocker Redirect MockGHSA-82fw-gwwq-j7x9 · 8 Sep 2026Fixed in 4.1.11
Release note
The section about @vitest/mocker of a note shared by several packages.
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.
Features
mocker: Introduce @vitest/mocker package, allow
{ spy: true }instead of a factoryMigrate 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
types: Allow Callbacks Passed to before*/after* to Return Anything
ui: Remove "filters" flickering
ui: Render project name consistently
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.