-
Notifications
You must be signed in to change notification settings - Fork 228
Expand file tree
/
Copy pathvitest-setup-client.ts
More file actions
38 lines (36 loc) · 990 Bytes
/
vitest-setup-client.ts
File metadata and controls
38 lines (36 loc) · 990 Bytes
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
import '@testing-library/jest-dom/vitest';
import { beforeAll, vi } from 'vitest';
// required for svelte5 + jsdom as jsdom does not support matchMedia
Object.defineProperty(window, 'matchMedia', {
writable: true,
enumerable: true,
value: vi.fn().mockImplementation((query) => ({
matches: false,
media: query,
onchange: null,
addEventListener: vi.fn(),
removeEventListener: vi.fn(),
dispatchEvent: vi.fn()
}))
});
beforeAll(() => {
vi.mock('$app/environment', () => ({
dev: true,
building: true,
browser: true,
page: {
params: {
project: 'tests',
region: 'tests'
}
}
}));
vi.mock('$app/navigation', () => ({
goto: vi.fn(),
beforeNavigate: vi.fn()
}));
vi.mock('$env/static/public', () => import.meta.env);
vi.mock('$env/dynamic/public', () => ({
env: import.meta.env
}));
});