vitest.workspace.mts 1.1 KB

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