Writes Vitest + RTL tests covering the virtual list threshold (>50 rows), fallback path (≤50), directory collapse/expand, tab-switch scroll preservation, file-click callback, and root-level files. Also aliases react/react-dom to the parent monorepo copies in vitest.config.ts so all components share the same ReactSharedInternals dispatcher — fixing the pre-existing null-dispatcher hook errors that affected all web component tests in this git worktree. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
46 lines
1.6 KiB
TypeScript
46 lines
1.6 KiB
TypeScript
import { defineConfig } from 'vitest/config';
|
|
import react from '@vitejs/plugin-react';
|
|
import path from 'node:path';
|
|
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
resolve: {
|
|
// Alias react to the parent monorepo's copy, matching what @testing-library
|
|
// loads react-dom from. This ensures React DOM and our components share the
|
|
// same ReactSharedInternals and hook dispatcher — preventing null-dispatcher
|
|
// errors when running tests from a git worktree.
|
|
alias: {
|
|
'@': path.resolve(__dirname, './apps/web/src'),
|
|
react: path.resolve(__dirname, '../../../../node_modules/react'),
|
|
'react-dom': path.resolve(__dirname, '../../../../node_modules/react-dom'),
|
|
},
|
|
dedupe: ['react', 'react-dom'],
|
|
},
|
|
test: {
|
|
// Force react-dom and @testing-library through Vite's module graph so that
|
|
// the resolve.alias for 'react-dom' applies (prevents parent-monorepo
|
|
// react-dom loading a different React instance than our source files).
|
|
deps: {
|
|
inline: ['react-dom', '@testing-library/react'],
|
|
},
|
|
// Enable test globals (describe, it, expect without imports)
|
|
globals: true,
|
|
env: {
|
|
CW_LOG_LEVEL: 'silent',
|
|
},
|
|
// Test file pattern
|
|
include: ['**/*.test.ts', '**/*.test.tsx'],
|
|
exclude: ['**/node_modules/**', '**/dist/**', 'packages/**'],
|
|
environmentMatchGlobs: [
|
|
['apps/web/**', 'happy-dom'],
|
|
],
|
|
// TypeScript support uses tsconfig.json automatically
|
|
// Coverage reporter (optional, for future use)
|
|
coverage: {
|
|
provider: 'v8',
|
|
reporter: ['text', 'json', 'html'],
|
|
reportsDirectory: './apps/server/coverage',
|
|
},
|
|
},
|
|
});
|