Packages

@vitest/spy

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

Your version

0.31.0

3 May 2023Where it was published

0.34.7 is the newest release of 0.31.x.

In short

2 breaking7 new18 fixed1 internal

  • breaking

    Remove browser from allowed pools inside poolMatchGlob config option. Please, use Vitest workspaces for running tests in the browser.

  • breaking

    Move assertion declarations to expect package

Release note

Breaking Changes

  • breaking

    Remove browser from allowed pools inside poolMatchGlob config option. Please, use Vitest workspaces for running tests in the browser.

  • breaking

    Move assertion declarations to expect package

    • The change should be minor:

    - declare namespace Vi {
    + declare module 'vitest' {
       interface Assertion<T = any> extends CustomMatchers<T> {}
       interface AsymmetricMatchersContaining extends CustomMatchers {}
    }

Features

  • Update mock implementation to support ESM runtime, introduce "vi.hoisted"

    • Bypass ESM import order restriction with vi.hoisted to run code before imports are executed:

    vi.hoisted(() => vi.setSystemTime(new Date(2022, 1, 1)))

    You can also use it to pass variables to vi.mock:

    const { mockedMethod } = vi.hoisted(() => {
      return { mockedMethod: vi.fn() }
    })   
    vi.mock('./path/to/module.js', () => {
      return { originalMethod: mockedMethod }
    })
  • Add repeat method to tests

  • Add an option to hide skipped test lines

  • coverage: Watermarks for c8

  • ui: Add html coverage

  • watch: Test run cancelling, feat: --bail option for cancelling test run

Bug Fixes

  • Don't call global setup teardown twice

  • Reporter to log version before provider initalizations

  • Throw an error if Vitest cannot access its internal state

  • Warning suppression broken

  • Show correct diff in "toHaveBeenCalledWith"

  • Don't print esm warning, if package name is not found

  • Support exactOptionalPropertyTypes

  • Don't inline vite hmr and rollup types

  • browser: Failing to load vitest/utils

  • coverage: thresholdAutoUpdate to work with perFile

  • coverage: Throw error if fail to load built-in provider

  • coverage: Stackblitz hangs with c8

  • coverage: C8 to ignore vite's generated helpers

  • coverage: Workspaces c8 source maps

  • spy: Update to set initial implementation through normal logic

  • vite-node: Circular imports

  • vite-node: Add missing import.meta.hot.send mock

  • vitest: Also check for vite relative to vitest package

  • watch: Run test files when added to filesystem