mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
Hermetic E2E harness targeting pricing integrity and backoffice config: - e2e/ docker Postgres (5544) + prepare.sh/run.sh one-command runner + HTML report - 6 suites / 23 tests reproducing pricing, FX, wallet, refund, config and auth defects (see docs/ISSUES.md); docs/e2e-test-matrix.md documents the matrix - two-tier harness (slim module boot + direct service instantiation) to work around the IAM/RabbitMQ/file-type boot wall - .env.test.example tracked; loader falls back to it for fresh checkouts Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
27 lines
935 B
TypeScript
27 lines
935 B
TypeScript
/**
|
|
* Singleton PrismaClient against the hermetic test DB (DATABASE_URL from .env.test, loaded by
|
|
* setup/load-env.ts). Used by:
|
|
* - the fixture seeder (fixtures/seed-core.ts), and
|
|
* - "direct-instantiation" specs for services behind the IAM/RabbitMQ wall (BookingsService,
|
|
* PaymentsService, WalletService, …) which cannot be booted through their Nest modules because
|
|
* those transitively import the @tria-plc IAM stack (ESM-only `file-type`) / golevelup RabbitMQ.
|
|
* Those specs `new TheService(prisma, ...mockedCollaborators)` and assert the money logic.
|
|
*/
|
|
import { PrismaClient } from "@prisma/client";
|
|
|
|
let client: PrismaClient | undefined;
|
|
|
|
export function getTestPrisma(): PrismaClient {
|
|
if (!client) {
|
|
client = new PrismaClient();
|
|
}
|
|
return client;
|
|
}
|
|
|
|
export async function disconnectTestPrisma(): Promise<void> {
|
|
if (client) {
|
|
await client.$disconnect();
|
|
client = undefined;
|
|
}
|
|
}
|