-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvitest.setup.ts
More file actions
75 lines (68 loc) · 1.71 KB
/
vitest.setup.ts
File metadata and controls
75 lines (68 loc) · 1.71 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
73
74
75
import "@testing-library/jest-dom";
import { afterEach, beforeAll } from "vitest";
import { cleanup } from "@testing-library/react";
// Setup GSAP for testing environment
beforeAll(() => {
// Mock GSAP animations in tests
const mockGSAP = {
set: () => {},
to: () => Promise.resolve(),
from: () => Promise.resolve(),
fromTo: () => Promise.resolve(),
timeline: () => ({
to: () => mockGSAP,
from: () => mockGSAP,
set: () => mockGSAP,
kill: () => {},
}),
registerPlugin: () => {},
getById: () => null,
killTweensOf: () => {},
};
(global as any).gsap = mockGSAP;
});
// Cleanup after each test
afterEach(() => {
cleanup();
});
// Mock window.matchMedia for responsive testing
Object.defineProperty(window, "matchMedia", {
writable: true,
value: (query: string) => ({
matches: false,
media: query,
onchange: null,
addListener: () => {},
removeListener: () => {},
addEventListener: () => {},
removeEventListener: () => {},
dispatchEvent: () => {},
}),
});
// Mock CSS custom properties support
Object.defineProperty(window, "CSS", {
writable: true,
value: {
supports: (_property: string, _value: string) => true,
},
});
// Mock ResizeObserver for responsive components
(global as any).ResizeObserver = class ResizeObserver {
observe() {}
unobserve() {}
disconnect() {}
};
// Mock IntersectionObserver for visibility testing
(global as any).IntersectionObserver = class IntersectionObserver {
constructor(
_callback: IntersectionObserverCallback,
_options?: IntersectionObserverInit
) {}
observe() {}
unobserve() {}
disconnect() {}
root = null;
rootMargin = "";
thresholds = [];
takeRecords = () => [];
};