[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
vitest docs config restoremocks.md
744 B


title: restoreMocks | Config outline: deep #

restoreMocks #

  • Type: boolean
  • Default: false

Should Vitest automatically call vi.restoreAllMocks() before each test.

This restores all original implementations on spies created manually with vi.spyOn.

import { defineConfig } from 'vitest/config'

export default defineConfig({
  test: {
    restoreMocks: true,
  },
})

::: warning Be aware that this option may cause problems with async concurrent tests. If enabled, the completion of one test will restore the implementation for all spies, including those currently being used by other tests in progress. :::