This repo reproduces a Prisma Client codegen quirk in tests and shows a small workaround to run the suite.
- Node.js 18+
- A PostgreSQL database and
DATABASE_URLenvironment variable
npm iSet DATABASE_URL in your environment (adjust values to your local DB):
export DATABASE_URL="postgresql://user:password@localhost:5432/prisma_bug?schema=public"npm run generatenpm test- Prisma Client generated with the current settings emits a top-level
const __dirname = '/'insidegenerated/prisma/client.ts. - In Jest, this can conflict and cause import/runtime issues.
- As a temporary, non-breaking workaround, the Jest config applies a tiny pre-test text replacement to rename that local
__dirnameto__prisma_dirname, and updates the call site accordingly. This avoids collisions without touching source code.
You can see the workaround near the top of jest.config.ts.