Skip to content

clearMocks

  • Type: boolean
  • Default: false

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

This will clear mock history without affecting mock implementations.

vitest.config.js
js
import { defineConfig } from 'vitest/config'

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

Released under the MIT License.