715 B
715 B
Built-In Mocks
@nuxt/test-utils provides built-in mocks for browser APIs in the DOM test environment.
intersectionObserver
- Default:
true - Creates a dummy class without any functionality for the IntersectionObserver API.
indexedDB
- Default:
false - Uses
fake-indexeddbto create a functional mock of the IndexedDB API.
Configuration
// vitest.config.ts
import { defineVitestConfig } from '@nuxt/test-utils/config'
export default defineVitestConfig({
test: {
environmentOptions: {
nuxt: {
mock: {
intersectionObserver: true,
indexedDb: true,
},
},
},
},
})