test: set up Vitest with 61 frontend tests
Add Vitest + testing-library/react + jsdom for frontend testing. Tests cover: cn() utility (6), usePermissions hook (27), useTreeValidation hook (22), and userPreferencesStore (6). CI updated to run frontend tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
16
frontend/src/test/setup.ts
Normal file
16
frontend/src/test/setup.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
|
||||
// Mock localStorage for zustand persist middleware
|
||||
const localStorageMock = (() => {
|
||||
let store: Record<string, string> = {}
|
||||
return {
|
||||
getItem: (key: string) => store[key] ?? null,
|
||||
setItem: (key: string, value: string) => { store[key] = value },
|
||||
removeItem: (key: string) => { delete store[key] },
|
||||
clear: () => { store = {} },
|
||||
get length() { return Object.keys(store).length },
|
||||
key: (index: number) => Object.keys(store)[index] ?? null,
|
||||
}
|
||||
})()
|
||||
|
||||
Object.defineProperty(globalThis, 'localStorage', { value: localStorageMock })
|
||||
Reference in New Issue
Block a user