0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-23 20:33:16 -05:00
logto/packages/core/jest.setup.js
2023-02-12 23:37:47 +08:00

34 lines
977 B
JavaScript

/**
* Setup environment variables for unit test
*/
import { createMockUtils } from '@logto/shared/esm';
const { jest } = import.meta;
const { mockEsm, mockEsmDefault } = createMockUtils(jest);
process.env.DB_URL = 'postgres://mock.db.url';
process.env.ENDPOINT = 'https://logto.test';
process.env.NODE_ENV = 'test';
/* Mock for EnvSet */
mockEsm('#src/libraries/logto-config.js', () => ({
createLogtoConfigLibrary: () => ({ getOidcConfigs: () => ({}) }),
}));
mockEsm('#src/env-set/check-alteration-state.js', () => ({
checkAlterationState: () => true,
}));
// eslint-disable-next-line unicorn/consistent-function-scoping
mockEsmDefault('#src/env-set/oidc.js', () => () => ({
issuer: 'https://logto.test/oidc',
cookieKeys: [],
privateJwks: [],
publicJwks: [],
}));
/* End */
// Logger is not considered in all test cases
// eslint-disable-next-line unicorn/consistent-function-scoping
mockEsm('koa-logger', () => ({ default: () => (_, next) => next() }));