forked from lark-parser/ide
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest-setup-server.ts
More file actions
41 lines (36 loc) · 1.05 KB
/
vitest-setup-server.ts
File metadata and controls
41 lines (36 loc) · 1.05 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
import { vi } from 'vitest';
// Setup jsdom globals
import { beforeAll } from 'vitest';
beforeAll(() => {
// Mock console methods to reduce noise in tests
global.console.warn = vi.fn();
global.console.error = vi.fn();
// Mock URL.createObjectURL and URL.revokeObjectURL for file downloads
global.URL.createObjectURL = vi.fn(() => 'mocked-object-url');
global.URL.revokeObjectURL = vi.fn();
// Mock window.matchMedia for breakpoint tests
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: 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()
}))
});
// Mock localStorage for theme tests
const localStorageMock = {
getItem: vi.fn(),
setItem: vi.fn(),
removeItem: vi.fn(),
clear: vi.fn()
};
Object.defineProperty(window, 'localStorage', {
value: localStorageMock,
writable: true
});
});