-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.setup.ts
More file actions
43 lines (41 loc) · 1.03 KB
/
vitest.setup.ts
File metadata and controls
43 lines (41 loc) · 1.03 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
import "@testing-library/jest-dom";
import { vi } from "vitest";
import React from "react";
// Mock framer-motion so motion.div renders as a plain div in tests
vi.mock("framer-motion", () => {
// Keys to strip from props before passing to React.createElement
const MOTION_PROPS = new Set([
"initial",
"animate",
"exit",
"transition",
"variants",
"whileHover",
"whileTap",
]);
return {
motion: new Proxy(
{},
{
get: (_target, prop: string) => (props: Record<string, unknown>) => {
const domProps: Record<string, unknown> = {};
for (const [key, value] of Object.entries(props)) {
if (!MOTION_PROPS.has(key)) {
domProps[key] = value;
}
}
return React.createElement(
prop,
domProps,
props.children as React.ReactNode,
);
},
},
),
AnimatePresence: ({
children,
}: {
children?: React.ReactNode;
}): React.ReactNode => children,
};
});