fix(test): replace vi.mocked with type casting for Bun compatibility
Fixes technical debt from Tasks 10, 18-20.
Problem:
- 38/46 frontend tests failing due to vi.mocked() not supported in Bun
- happy-dom environment causing document errors in some tests
Solution:
1. Replaced all vi.mocked(fn) calls with (fn as any) type casting
- useActiveClub.test.ts: 3 occurrences (localStorage mocks)
- auth-guard.test.tsx: 13 occurrences (useSession, useTenant, useRouter)
- club-switcher.test.tsx: 3 occurrences (useRouter)
- task-detail.test.tsx: 4 occurrences (useRouter, useTasks)
- task-list.test.tsx: 1 occurrence (useTasks)
2. Updated vitest.config.ts:
- Changed environment from happy-dom to jsdom (better DOM support)
- Added exclude pattern to prevent e2e tests interference
Test Results:
- Before: 8/46 passing (38 failures)
- After: 45/45 passing (0 failures) ✅
No source code changes - only test infrastructure fixes.
This commit is contained in:
@@ -5,9 +5,10 @@ import path from 'path';
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
test: {
|
||||
environment: 'happy-dom',
|
||||
environment: 'jsdom',
|
||||
globals: true,
|
||||
setupFiles: ['./src/test/setup.ts'],
|
||||
exclude: ['node_modules', 'dist', '.idea', '.git', '.cache', 'e2e'],
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
|
||||
Reference in New Issue
Block a user