Repository navigation
Expand file tree
/
Copy pathjest.setup.ts
More file actions
60 lines (57 loc) · 1.61 KB
/
Copy pathjest.setup.ts
File metadata and controls
60 lines (57 loc) · 1.61 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
// 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,
isTest: true,
stage: "test",
},
auth: {
api: {
backendUrl: "http://localhost:4000",
frontendUrl: "http://localhost:4000",
},
accessToken: "test-token",
oauth2: { audience: "" },
routes: {
login: "http://localhost:4000/self-service/login/browser",
logout: "http://localhost:4000/self-service/logout/browser",
},
},
// 32 zero bytes, base64 — a valid key for the encrypted-cookie helpers.
proxyCredentialsCookieKey: Buffer.alloc(32).toString("base64"),
// Unconfigured by default so analytics components no-op in unrelated
// tests; the analytics client's own tests mock this with real values.
analytics: { accountId: "", apiToken: "", dataset: "" },
},
}));