import { defineConfig, configDefaults } from 'vitest/config'; import react from '@vitejs/plugin-react'; import path from 'path'; import { fileURLToPath } from 'node:url'; // Storybook test plugin — uncomment storybookTest and the browser project below // to run story-based visual tests (requires Playwright to be installed). // 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) // The following tests are excluded because their underlying components/hooks // are not yet implemented. They are tracked as future work items: '**/usePlaylistKeyboardShortcuts.test.ts', // TODO(T0507): Implement keyboard shortcuts hook '**/PlaylistVersionHistory.test.tsx', // TODO(T0509): Implement version history component '**/ShareLinkButton.test.tsx', // TODO(T0488): Implement share link button component '**/PlaylistAccessibility.test.tsx', // TODO(T0503): Add vitest-axe dependency for a11y testing '**/useRoutePreload-additional.test.ts', // TODO: Fix fake timers + renderHook incompatibility // Components not yet implemented — tests reference non-existent source files: '**/tracks/components/CommentForm.test.tsx', // TODO: Implement CommentForm component '**/tracks/components/CommentItem.test.tsx', // TODO: Implement CommentItem component '**/tracks/components/PlaysChart.test.tsx', // TODO: Implement PlaysChart component '**/tracks/components/ShareLinkDisplay.test.tsx', // TODO: Implement ShareLinkDisplay component '**/tracks/components/TrackDelete.test.tsx', // TODO: Implement TrackDelete component '**/tracks/components/TrackDownloadButton.test.tsx', // TODO: Implement TrackDownloadButton component '**/tracks/components/TrackEdit.test.tsx', // TODO: Implement TrackEdit component '**/tracks/components/TrackShareDialog.test.tsx', // TODO: Implement TrackShareDialog component '**/tracks/components/TrackUpload.test.tsx', // TODO: Implement TrackUpload component '**/tracks/components/TrackVersionHistory.test.tsx', // TODO: Implement TrackVersionHistory component '**/streaming/components/BitrateAnalytics.test.tsx', // TODO: Implement BitrateAnalytics component '**/streaming/components/HLSPlayer.test.tsx', // TODO: Implement HLSPlayer component '**/profile/components/ProfileEditForm.test.tsx', // TODO: Implement ProfileEditForm component ], 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: { global: { branches: 80, functions: 80, lines: 80, statements: 80, }, }, }, // projects: [ // { // extends: true, // plugins: [ // // The plugin will run tests for the stories defined in your Storybook config // // See options at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon#storybooktest // // storybookTest({ // // configDir: path.join(dirname, '.storybook'), // // }), // ], // test: { // name: 'storybook', // browser: { // enabled: true, // headless: true, // provider: 'playwright', // instances: [ // { // browser: 'chromium', // }, // ], // }, // setupFiles: ['.storybook/vitest.setup.ts'], // }, // }, // { // extends: true, // plugins: [ // // The plugin will run tests for the stories defined in your Storybook config // // See options at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon#storybooktest // // storybookTest({ // // configDir: path.join(dirname, '.storybook'), // // }), // ], // test: { // name: 'storybook', // browser: { // enabled: true, // headless: true, // provider: 'playwright', // instances: [ // { // browser: 'chromium', // }, // ], // }, // setupFiles: ['.storybook/vitest.setup.ts'], // }, // }, // { // extends: true, // plugins: [ // // The plugin will run tests for the stories defined in your Storybook config // // See options at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon#storybooktest // // storybookTest({ // // configDir: path.join(dirname, '.storybook'), // // }), // ], // test: { // name: 'storybook', // browser: { // enabled: true, // headless: true, // provider: 'playwright', // instances: [ // { // browser: 'chromium', // }, // ], // }, // setupFiles: ['.storybook/vitest.setup.ts'], // }, // }, // { // extends: true, // plugins: [ // // The plugin will run tests for the stories defined in your Storybook config // // See options at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon#storybooktest // // storybookTest({ // // configDir: path.join(dirname, '.storybook'), // // }), // ], // test: { // name: 'storybook', // browser: { // enabled: true, // headless: true, // provider: 'playwright', // instances: [ // { // browser: 'chromium', // }, // ], // }, // setupFiles: ['.storybook/vitest.setup.ts'], // }, // }, // { // extends: true, // plugins: [ // // The plugin will run tests for the stories defined in your Storybook config // // See options at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon#storybooktest // // storybookTest({ // // configDir: path.join(dirname, '.storybook'), // // }), // ], // test: { // name: 'storybook', // browser: { // enabled: true, // headless: true, // provider: 'playwright', // instances: [ // { // browser: 'chromium', // }, // ], // }, // setupFiles: ['.storybook/vitest.setup.ts'], // }, // }, // ], }, 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'), }, }, });