-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.config.ts
More file actions
34 lines (29 loc) · 1.44 KB
/
jest.config.ts
File metadata and controls
34 lines (29 loc) · 1.44 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
import type { Config } from "jest";
// import path from "node:path";
// import fs from "node:fs";
// const prismaClientPath = path.resolve(__dirname, "generated", "prisma", "client.ts");
// // --- Temporary monkey-patch for generated Prisma client.ts ---
// // This is a non-breaking, temporary fix to work around a Prisma codegen issue
// // where the generated client uses `__dirname`, which can cause problems in our test environment.
// // We simply rename `__dirname` to `__prisma_dirname` and update its usage accordingly.
// try {
// let content = fs.readFileSync(prismaClientPath, "utf8");
// // Rename 'const __dirname = "/";' to 'const __prisma_dirname = "/";'
// content = content.replace(/^const __dirname = '\/'\s*$/m, 'const __prisma_dirname = "/"');
// // Replace 'getPrismaClientClass(__dirname)' with 'getPrismaClientClass(__prisma_dirname)'
// content = content.replace(/getPrismaClientClass\(__dirname\)/g, "getPrismaClientClass(__prisma_dirname)");
// fs.writeFileSync(prismaClientPath, content, "utf8");
// console.log("Patched Prisma client.ts for test environment (renamed __dirname to __prisma_dirname)");
// } catch (err) {
// console.error("Failed to patch Prisma client.ts:", err);
// }
// // --- End temporary patch ---
const config: Config = {
testEnvironment: "node",
testTimeout: 30000,
testMatch: ["**/+(*.)+(test).+(ts|js)?(x)"],
transform: {
"^.+\\.(ts|tsx)$": "@swc/jest",
},
};
export default config;