Initial commit
This commit is contained in:
33
.claude/skills/nuxt-testing/references/unit-mocks.md
Normal file
33
.claude/skills/nuxt-testing/references/unit-mocks.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# 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,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
```
|
||||
Reference in New Issue
Block a user