Packages

@vitest/snapshot

5.1.0 · 2 Nov 2026MIT134.2M / 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 breaking3 new8 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

The section about @vitest/snapshot of a note shared by several packages.

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

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

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.