Skip to content

Commit

Permalink
mock process.env instead
Browse files Browse the repository at this point in the history
  • Loading branch information
imolorhe committed Oct 28, 2024
1 parent fe69bbe commit 60791ce
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/altair-api/test/e2e-test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,13 @@ export const createQuery = async (app: INestApplication, collectionId: string) =
return res.body;
};

const originalEnv = process.env;
export const beforeAllSetup = async () => {
jest.resetModules();
process.env = {
...originalEnv,
RESEND_API_KEY: 're_test',
};
await cleanupDatabase(prisma);

// seed e2e test database
Expand Down Expand Up @@ -262,10 +268,6 @@ export const createTestApp = async () => {
.useValue(logger)
.overrideProvider(PrismaService)
.useValue(prisma)
.overrideProvider(ConfigService)
.useValue({
get: jest.fn().mockReturnValue('test'),
})
.compile();

expect(process.env.NODE_ENV).toBe('test');
Expand All @@ -287,6 +289,7 @@ export const afterAllCleanup = async (
app: INestApplication,
prismaService: PrismaService
) => {
process.env = originalEnv;
// await prismaService?.$disconnect();
// await prisma.$disconnect();
await app.close();
Expand Down

0 comments on commit 60791ce

Please sign in to comment.