1
0

vitest.config.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import path from 'node:path';
  2. import { fileURLToPath } from 'node:url';
  3. import react from '@vitejs/plugin-react';
  4. import { storybookTest } from '@storybook/addon-vitest/vitest-plugin';
  5. import { playwright } from '@vitest/browser-playwright';
  6. import { defineConfig } from 'vitest/config';
  7. const dirname = typeof __dirname !== 'undefined' ? __dirname : path.dirname(fileURLToPath(import.meta.url));
  8. export default defineConfig({
  9. plugins: [react()],
  10. resolve: {
  11. alias: {
  12. '@': path.resolve(dirname, 'src'),
  13. },
  14. },
  15. test: {
  16. globals: false,
  17. projects: [
  18. {
  19. extends: true,
  20. test: {
  21. name: 'unit',
  22. include: ['src/test/**/*.test.ts'],
  23. environment: 'node',
  24. setupFiles: ['./src/test/setup.ts', './src/test/setup.msw.ts'],
  25. },
  26. },
  27. {
  28. extends: true,
  29. test: {
  30. name: 'components',
  31. include: ['src/test/**/*.test.tsx'],
  32. environment: 'jsdom',
  33. setupFiles: ['./src/test/setup.ts', './src/test/setup.components.ts'],
  34. },
  35. },
  36. {
  37. extends: true,
  38. optimizeDeps: {
  39. include: ['aria-query', 'lz-string', 'pretty-format', 'dom-accessibility-api'],
  40. },
  41. plugins: [storybookTest({ configDir: path.join(dirname, '.storybook') })],
  42. test: {
  43. name: 'storybook',
  44. browser: {
  45. enabled: true,
  46. headless: true,
  47. provider: playwright({}),
  48. instances: [{ browser: 'chromium' }],
  49. },
  50. },
  51. },
  52. ],
  53. },
  54. });