vitest.workspace.mts 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import react from '@vitejs/plugin-react';
  2. import tsconfigPaths from 'vite-tsconfig-paths';
  3. import { defineConfig, defineWorkspace, mergeConfig } from 'vitest/config';
  4. const configShared = defineConfig({
  5. plugins: [tsconfigPaths()],
  6. test: {
  7. clearMocks: true,
  8. globals: true,
  9. exclude: ['test/**', 'test-with-vite/**', 'playwright/**'],
  10. },
  11. });
  12. export default defineWorkspace([
  13. // unit test
  14. mergeConfig(configShared, {
  15. test: {
  16. name: 'app-unit',
  17. environment: 'node',
  18. include: ['**/*.spec.{ts,js}'],
  19. },
  20. }),
  21. // integration test
  22. mergeConfig(configShared, {
  23. test: {
  24. name: 'app-integration',
  25. environment: 'node',
  26. include: ['**/*.integ.ts'],
  27. setupFiles: ['./test-with-vite/setup/mongoms.ts'],
  28. },
  29. }),
  30. // component test
  31. mergeConfig(configShared, {
  32. plugins: [react()],
  33. test: {
  34. name: 'app-components',
  35. environment: 'happy-dom',
  36. include: ['**/*.spec.{tsx,jsx}'],
  37. setupFiles: ['./test-with-vite/setup/jest-dom.ts'],
  38. },
  39. }),
  40. ]);