-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.setup.ts
More file actions
60 lines (56 loc) · 1.83 KB
/
jest.setup.ts
File metadata and controls
60 lines (56 loc) · 1.83 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
import "@testing-library/jest-dom";
import "whatwg-fetch";
import { TextEncoder, TextDecoder } from "util";
global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoder as any;
// Polyfill for Request, Response, Headers if not available (Next.js server side needs these)
if (typeof Request === "undefined") {
global.Request = require("node-fetch").Request as any;
global.Response = require("node-fetch").Response as any;
global.Headers = require("node-fetch").Headers as any;
}
// Polyfill for Response.json if not available
if (typeof Response.json === "undefined") {
(Response as any).json = (data: any, init?: any) => {
const body = JSON.stringify(data);
return new Response(body, {
...init,
headers: {
"Content-Type": "application/json",
...(init?.headers || {}),
},
});
};
}
// Global mock for lucide-react icons
jest.mock("lucide-react", () => ({
Sun: () => "SunIcon",
Moon: () => "MoonIcon",
Search: () => "SearchIcon",
User: () => "UserIcon",
ArrowRight: () => "ArrowRightIcon",
Check: () => "CheckIcon",
X: () => "XIcon",
AlertCircle: () => "AlertCircleIcon",
Calendar: () => "CalendarIcon",
Clock: () => "ClockIcon",
Tag: () => "TagIcon",
Menu: () => "MenuIcon",
Mail: () => "MailIcon",
Github: () => "GithubIcon",
Twitter: () => "TwitterIcon",
Linkedin: () => "LinkedinIcon",
ExternalLink: () => "ExternalLinkIcon",
Image: () => "ImageIcon",
Plus: () => "PlusIcon",
Trash: () => "TrashIcon",
Edit: () => "EditIcon",
ChevronLeft: () => "ChevronLeftIcon",
ChevronRight: () => "ChevronRightIcon",
Eye: () => "EyeIcon",
Settings: () => "SettingsIcon",
LogOut: () => "LogOutIcon",
LayoutDashboard: () => "LayoutDashboardIcon",
FileText: () => "FileTextIcon",
Users: () => "UsersIcon",
}));