veza/apps/web/vitest.config.ts
senke b97c2757ca fix(tests): add missing component tests and fix failing tests
- Fix setTimeout memory leak in ChatRoom.tsx by storing timeout in
  useRef and cleaning up on unmount
- Add tests for Accordion, Collapsible, FloatingInput, AnimatedNumber,
  and FAB components (5 new test files, all passing)
- Fix socialService methods (deleteComment, markRead, markAllRead) to
  return values matching test expectations
- Fix MSW handlers for chat/token and notification endpoints to use
  proper { success: true, data: ... } envelope format
- Fix invalid CSS selector in TrackList.test.tsx that caused JSDOM crash
- Document excluded test files with TODO tickets in vitest.config.ts

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 22:59:09 +01:00

187 lines
6.4 KiB
TypeScript

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)
// 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
],
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'),
},
},
});