import { defineConfig, configDefaults } from 'vitest/config'; import react from '@vitejs/plugin-react'; import path from 'path'; import { fileURLToPath } from 'node:url'; import { storybookTest } from '@storybook/addon-vitest/vitest-plugin'; const dirname = typeof __dirname !== 'undefined' ? __dirname : path.dirname(fileURLToPath(import.meta.url)); // More info at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon export default defineConfig({ plugins: [react()], test: { globals: true, environment: 'jsdom', setupFiles: ['./src/test/setup.ts', './src/mocks/test-setup.ts'], exclude: [ ...configDefaults.exclude, '**/e2e/**', // Playwright E2E tests (run via playwright test) '**/*.stories.tsx', // Storybook stories run via `vitest --project storybook` '**/*.stories.ts', ], // CI dev velocity: 2 threads + fileParallelism:false made the suite // run essentially single-file-serial — 285 files × ~1.2s avg = ~6min // wall time on a 12-core R720. Lifting both caps brings it to ~60-90s. // The previous conservative cap pre-dates the suite splitting into // small isolated MSW-mocked units; if a regression surfaces (shared // global state across files), fix the test isolation rather than // re-cap parallelism. pool: 'threads', poolOptions: { threads: { maxThreads: 6, minThreads: 1, }, }, fileParallelism: true, coverage: { provider: 'v8', reporter: ['text', 'json', 'html'], exclude: [ 'node_modules/', 'src/test/', '**/*.d.ts', '**/*.config.*', '**/coverage/**', '**/dist/**', '**/.{idea,git,cache,output,temp}/**', '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*', ], thresholds: { // v1.0.2: ROADMAP critère 5 > 50% global global: { branches: 50, functions: 50, lines: 50, statements: 50, }, }, }, }, resolve: { alias: { '@': path.resolve(__dirname, './src'), '@components': path.resolve(__dirname, './src/components'), '@pages': path.resolve(__dirname, './src/pages'), '@hooks': path.resolve(__dirname, './src/hooks'), '@services': path.resolve(__dirname, './src/services'), '@types': path.resolve(__dirname, './src/types'), '@utils': path.resolve(__dirname, './src/utils'), '@stores': path.resolve(__dirname, './src/stores'), '@locales': path.resolve(__dirname, './src/locales'), }, }, });