Skip to content

Commit f35c22a

Browse files
d-csclaude
andcommitted
test(webapp): isolate mollifierDrainerWorker test from runEngine singleton
Importing the production drainer wiring transitively loads \`~/v3/runEngine.server\`, whose top-level \`singleton(...)\` eagerly constructs a RunEngine. The constructor spins up Prisma + Redis workers that try to connect to localhost — in CI (no PG, no Redis) that produces an unhandled \`PrismaClientInitializationError\` which fails the run even though every assertion passes. Mock the runEngine and prisma modules so the unit test exercises only the bootstrap's error classification, not a live engine. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 062bcfa commit f35c22a

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

apps/webapp/test/mollifierDrainerWorker.test.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1-
import { describe, expect, it } from "vitest";
1+
import { describe, expect, it, vi } from "vitest";
2+
3+
// Importing `~/v3/mollifier/mollifierDrainer.server` (below) transitively
4+
// loads `~/v3/runEngine.server`, whose top-level `singleton(...)` call
5+
// eagerly constructs a RunEngine. That spins up Prisma + Redis workers
6+
// that try to connect to localhost — which in CI (no PG, no Redis)
7+
// produces an unhandled `PrismaClientInitializationError` that fails
8+
// the test run even though the assertions all pass. Mocking the
9+
// runEngine module short-circuits the singleton so no worker starts.
10+
vi.mock("~/v3/runEngine.server", () => ({ engine: {} }));
11+
// Same problem: prisma.server.ts's top-level singleton tries to open a
12+
// PG client. The test never makes a query; an empty stub is enough.
13+
vi.mock("~/db.server", () => ({ prisma: {}, $replica: {} }));
14+
215
import { MollifierConfigurationError } from "~/v3/mollifier/mollifierDrainer.server";
316
import { initMollifierDrainerWorker } from "~/v3/mollifierDrainerWorker.server";
417

0 commit comments

Comments
 (0)