vitest.config.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { fileURLToPath, URL } from 'node:url'
  2. import { defineConfig } from 'vitest/config'
  3. import vue from '@vitejs/plugin-vue'
  4. export default defineConfig({
  5. plugins: [vue()],
  6. resolve: {
  7. alias: {
  8. '@': fileURLToPath(new URL('./src', import.meta.url))
  9. }
  10. },
  11. test: {
  12. environment: 'happy-dom',
  13. include: ['tests/unit/**/*.{test,spec}.ts'],
  14. globals: true,
  15. setupFiles: ['./vitest.setup.ts'],
  16. coverage: {
  17. provider: 'v8',
  18. reporter: ['text', 'text-summary', 'html', 'lcov'],
  19. reportsDirectory: './coverage',
  20. include: ['src/**/*.ts', 'src/**/*.vue'],
  21. exclude: [
  22. 'src/main.ts',
  23. 'src/env.d.ts',
  24. 'src/**/*.d.ts',
  25. 'src/types/**',
  26. // Exclude demo and test views that are not core functionality
  27. 'src/views/demo/**',
  28. 'src/views/test/**',
  29. 'src/views/cc/**',
  30. 'src/views/monitor/**',
  31. 'src/views/stream/**',
  32. 'src/views/camera/channel.vue',
  33. 'src/views/camera/stream-test.vue',
  34. 'src/views/camera/video.vue',
  35. // Exclude layout and router (tested via E2E)
  36. 'src/layout/**',
  37. 'src/router/**',
  38. // Exclude complex components/composables that are hard to unit test
  39. 'src/components/VideoPlayer.vue',
  40. 'src/components/monitor/**',
  41. 'src/components/ThemeSettings.vue',
  42. 'src/components/PtzController.vue',
  43. 'src/components/HelloWorld.vue',
  44. 'src/composables/**',
  45. // Exclude complex API modules with external dependencies
  46. 'src/api/ptz.ts',
  47. 'src/api/stream.ts',
  48. 'src/api/cloudflare-stream.ts',
  49. 'src/store/stream.ts',
  50. 'src/store/index.ts',
  51. 'src/utils/request.ts'
  52. ],
  53. // Coverage thresholds - target 60%
  54. thresholds: {
  55. statements: 60,
  56. branches: 50,
  57. functions: 50,
  58. lines: 60
  59. }
  60. }
  61. }
  62. })