Packages

@vitest/spy

5.0.5 · 15 Oct 2026MIT202.7M / weekRepositoryHomepagenpmAtom feed

Your version

4.1.0

12 Mar 2026Where it was published

4.1.12 is the newest release of 4.x.

In short

1 removed3 deprecated47 new1 faster78 fixed2 internal

  • removed

    browser: Remove --remote-debugging-address from chrome args

  • deprecated

    Deprecate several vitest/* entry points

  • deprecated

    Deprecate unused types in matcher context

  • deprecated

    Deprecate toBe* spy assertions in favor of toHaveBeen* (and toThrowError)

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 setTickMode to timer controls

  • Expose matcher types

  • Add toTestSpecification to reported tasks

  • Show a warning if vi.mock or vi.hoisted are declared outside of top level of the module

  • Track and display expectedly failed tests (.fails) in UI and CLI

  • Support tags

  • Implement aroundEach and aroundAll hooks

  • Stabilize experimental features

  • Accept new or all in --update flag

  • Support meta in test options

  • Support type inference with a new test.extend syntax

  • Support 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 list to statically collect tests instead of running files to collect them

  • Add --detect-async-leaks

  • Implement mockThrow and mockThrowOnce

  • Support update: "none" and add docs about snapshots behavior on CI

  • Support playwright launchOptions with connectOptions

  • Add page/locator.mark API to enhance playwright trace

  • api: Support tests starting or ending with test in experimental_parseSpecification

  • api: Add filters to createSpecification

  • api: Expose runTestFiles as alternative to runTestSpecifications

  • api: Add allowWrite and allowExec options to api

  • api: Allow passing down test cases to toTestSpecification

  • browser: Add userEvent.wheel API

  • browser: Add filterNode option to prettyDOM for filtering browser assertion error output

  • browser: Support playwright persistent context

  • browser: Added detailsPanelPosition option and button

  • browser: Use BlazeDiff instead of pixelmatch

  • browser: Add findElement and enable strict mode in webdriverio and preview

  • cli: Add @bomb.sh/tab completions

  • coverage: Support ignore start/stop ignore hints

  • coverage: Add coverage.changed option to report only changed files

  • experimental: Add onModuleRunner hook to worker.init

  • experimental: Option to disable the module runner

  • experimental: Add importDurations: { limit, print } options

  • experimental: Add print and fail thresholds for importDurations

  • fixtures: Pass down file context to beforeAll/afterAll

  • reporters: Add agent reporter to reduce ai agent token usage

  • runner: Enhance retry options

  • ui: 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.url in createRequire

  • Preact browser mode init example of render function not async

  • deprecated

    Deprecate unused types in matcher context

  • Handle external/noExternal during configEnvironment hook

  • Replace default ssr environment runner with Vitest server module runner

  • Propagate experimental CLI options to child projects

  • Show a warning when browser.isolate is used

  • Fix vi.mock({ spy: true }) node v8 coverage

  • Don'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 .name from statically collected test

  • Don't suppress warnings on pnp

  • Support snapshot with expect.soft

  • Log seed when only sequence.shuffle.tests is enabled

  • Externalize expect/src/utils from vitest

  • Ignore test.override during static collection

  • Increase stacktrace limit for --detect-async-leaks

  • Hanging-reporter link in cli

  • Fix teardown timeout of aroundEach/All when inner aroundEach/All throws

  • Fix ui mode / html reporter and coverage integration

  • Don't continue when aroundEach/All setup timed out

  • Align VitestRunnerConfig optional fields with SerializedConfig

  • Handle Symbol values in format utility

  • deprecated

    Deprecate toBe* spy assertions in favor of toHaveBeen* (and toThrowError)

  • Don't propagate nested aroundEach/All errors but aggregate them on runner

  • Show a better error if there is a pending dynamic import

  • Preserve stack trace of resolves/rejects chained assertion error

  • Handle module-sync condition in vmThreads/vmForks require

  • Hooks should respect maxConcurrency

  • Recursively autospy module object

  • Remove trailing spaces from diff error log

  • Respect project resolve.conditions for externals

  • Use object for WeakMap instead of a symbol to support webcontainers

  • Fix re-mocking virtual module

  • Cancelling should stop current test immediately

  • Make mockObject change backwards compatible

  • Fix URL.name on jsdom

  • Save 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 modules

  • Throw FixtureAccessError if suite hook accesses undefined fixture

  • Allow hyphens in project config file name pattern

  • Manual and redirect mock shouldn't load or transform original module

  • hideSkippedTests should not hide test.todo

  • Allow catch/finally for async assertion

  • Resolve fixture overrides from test's suite in beforeEach hooks

  • Use isAgent check, not just TTY, for watch mode

  • Use performance.now to measure test timeout duration

  • Correctly identify concurrent test during static analysis

  • browser: Avoid updating screenshots when toMatchScreenshot passes

  • browser: 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-address from chrome args

  • browser: Make sure userEvent actions support ensureAwaited

  • browser: Types of getCDPSession and cdp()

  • browser: Skip esbuild.legalComments when using rolldown-vite

  • chai: Don't allow deepEqual in the config because it's not serializable

  • coverage: Infer transform mode for uncovered files

  • coverage: thresholds.autoUpdate to preserve ending whitespace

  • deps: 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 expect Map/Set on left hand side

  • expect: Fix objectContaining with proxy

  • expect: Support arbitrary value equality for toThrow and make Error detection robust

  • mock: Inject helpers after hashbang if present

  • mocker: Update vite's peer dependency range

  • reporter: dot reporter leaves pending tests

  • runner: 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 undefined

  • spy: Throw correct errors when shorthand methods are used on a class

  • types: bench.reporters no longer gives type errors when passing file name string paths

  • ui: Process artifact attachments when generating HTML reporter

  • ui: Don't fail if --ui and --root are specified together

Performance

  • pretty-format: Combine DOMElement plugins