34 lines
715 B
Markdown
34 lines
715 B
Markdown
# 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-indexeddb`](https://github.com/dumbmatter/fakeIndexedDB) to create a functional mock of the IndexedDB API.
|
|
|
|
## Configuration
|
|
|
|
```ts
|
|
// vitest.config.ts
|
|
import { defineVitestConfig } from '@nuxt/test-utils/config'
|
|
|
|
export default defineVitestConfig({
|
|
test: {
|
|
environmentOptions: {
|
|
nuxt: {
|
|
mock: {
|
|
intersectionObserver: true,
|
|
indexedDb: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
```
|