vitest.workspace.mts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. exclude: [
  14. 'test/**',
  15. 'test-with-vite/**',
  16. 'playwright/**',
  17. ],
  18. },
  19. });
  20. export default defineWorkspace([
  21. // unit test
  22. mergeConfig(
  23. configShared,
  24. {
  25. test: {
  26. name: 'app-unit',
  27. environment: 'node',
  28. include: ['**/*.spec.{ts,js}'],
  29. },
  30. },
  31. ),
  32. // integration test
  33. mergeConfig(
  34. configShared,
  35. {
  36. test: {
  37. name: 'app-integration',
  38. environment: 'node',
  39. include: ['**/*.integ.ts'],
  40. setupFiles: [
  41. './test-with-vite/setup/mongoms.ts',
  42. ],
  43. },
  44. },
  45. ),
  46. // component test
  47. mergeConfig(
  48. configShared,
  49. {
  50. plugins: [react()],
  51. test: {
  52. name: 'app-components',
  53. environment: 'happy-dom',
  54. include: [
  55. '**/*.spec.{tsx,jsx}',
  56. ],
  57. },
  58. },
  59. ),
  60. ]);