-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.setup.ts
More file actions
72 lines (65 loc) · 1.57 KB
/
vitest.setup.ts
File metadata and controls
72 lines (65 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import '@testing-library/jest-dom';
import { vi } from 'vitest';
import React from 'react';
// Make React available globally
global.React = React;
// Mock Next.js modules
vi.mock('next/navigation', () => ({
useRouter: () => ({
push: vi.fn(),
replace: vi.fn(),
back: vi.fn(),
forward: vi.fn(),
}),
usePathname: () => '/',
useSearchParams: () => new URLSearchParams(),
}));
// Mock Next.js Image component
vi.mock('next/image', () => ({
default: ({ src, alt, ...props }: any) => {
return React.createElement('img', { src, alt, ...props });
},
}));
// Mock Supabase
vi.mock('@/lib/supabase/config', () => ({
createClientComponentClient: () => ({
auth: {
getUser: vi.fn(),
signInWithPassword: vi.fn(),
signUp: vi.fn(),
signOut: vi.fn(),
},
storage: {
from: () => ({
getPublicUrl: () => ({ data: { publicUrl: 'test-url' } }),
upload: vi.fn(),
remove: vi.fn(),
}),
},
}),
createClient: () => ({
auth: {
getUser: vi.fn(),
},
}),
}));
// Global test environment setup
global.ResizeObserver = vi.fn().mockImplementation(() => ({
observe: vi.fn(),
unobserve: vi.fn(),
disconnect: vi.fn(),
}));
global.matchMedia = vi.fn().mockImplementation((query) => ({
matches: false,
media: query,
onchange: null,
addListener: vi.fn(),
removeListener: vi.fn(),
addEventListener: vi.fn(),
removeEventListener: vi.fn(),
dispatchEvent: vi.fn(),
}));
// Global Quill mock to prevent "Quill.register is not a function" errors
(global as any).Quill = {
register: vi.fn(),
};