test: stop mocking env vars in jest.utils (#53985)

This commit is contained in:
Oliver Eyton-Williams
2024-03-07 08:36:06 +01:00
committed by GitHub
parent 87762e9a93
commit 9f71d1c3ac
3 changed files with 23 additions and 28 deletions
-17
View File
@@ -7,23 +7,6 @@ import { createUserInput } from './src/utils/create-user';
import { examJson } from './__mocks__/exam';
import { MONGOHQ_URL } from './src/utils/env';
jest.mock('./src/utils/env', () => {
const createTestConnectionURL = (url: string, dbId: string) =>
url.replace(/(.*)(\?.*)/, `$1${dbId}$2`);
// There are other properties, and this type is too narrow, but we're only
// interested in MONGOHQ_URL here.
const actual: {
MONGOHQ_URL: string;
} = jest.requireActual('./src/utils/env');
return {
...actual,
MONGOHQ_URL: createTestConnectionURL(
actual.MONGOHQ_URL,
process.env.JEST_WORKER_ID!
)
};
});
type FastifyTestInstance = Awaited<ReturnType<typeof build>>;
declare global {