vitest.config.m.ts 1.01 KB
import { defineVitestConfig } from '@nuxt/test-utils/config'
import vue from '@vitejs/plugin-vue'
import { fileURLToPath } from 'node:url'

export default defineVitestConfig({
  /**
   * Documentation here : https://nuxt.com/docs/getting-started/testing
   * any custom Vitest config you require
   */
  test: {
    environment: 'nuxt',
    globals: true,
    // you can optionally set Nuxt-specific environment options
    environmentOptions: {
      nuxt: {
        rootDir: fileURLToPath(new URL('./', import.meta.url)),
        domEnvironment: 'happy-dom', // 'happy-dom' (default) or 'jsdom'
        overrides: {
          // other Nuxt config you want to pass
        },
        mock: {
          intersectionObserver: true,
          indexedDb: true,
        }
      },
    },
    coverage: {
      provider: 'v8',
      reporter: ['text', 'json', 'html'],
    }
  },
  resolve: {
    alias: {
      '~': fileURLToPath(new URL('./', import.meta.url)),
      '@': fileURLToPath(new URL('./', import.meta.url)),
    }
  }
})