-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathjest.setup.ts
More file actions
46 lines (43 loc) · 1002 Bytes
/
jest.setup.ts
File metadata and controls
46 lines (43 loc) · 1002 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
39
40
41
42
43
44
45
46
// jest.setup.ts
import { jest } from "@jest/globals";
import { Request, Response, Headers, fetch } from "undici";
import "@testing-library/jest-dom";
// Mock next/navigation
jest.mock("next/navigation", () => ({
useRouter: () => ({
push: jest.fn(),
replace: jest.fn(),
prefetch: jest.fn(),
}),
usePathname: () => "/",
}));
// @ts-ignore
global.Request = Request;
// @ts-ignore
global.Response = Response;
// @ts-ignore
global.Headers = Headers;
// @ts-ignore
global.fetch = fetch;
// Global mock for @/lib/config - can be overridden in individual test files
jest.mock("@/lib/config", () => ({
CONFIG: {
storage: {
type: "S3",
endpoint: "http://localhost:9000",
region: "us-east-1",
credentials: {
accessKeyId: "test",
secretAccessKey: "test",
},
},
environment: {
isDevelopment: false,
stage: "test",
},
auth: {
accessToken: "test-token",
},
apiSecret: "test-source-key-123",
},
}));