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.ts

35 lines
777 B
TypeScript
Raw Normal View History

/**
* Setup environment variables for unit test
*/
2022-11-21 03:38:24 -05:00
import envSet from '#src/env-set/index.js';
2022-11-21 03:38:24 -05:00
jest.mock('#src/lib/logto-config.js');
jest.mock('#src/env-set/check-alteration-state.js');
// eslint-disable-next-line unicorn/prefer-top-level-await
(async () => {
await envSet.load();
})();
2022-11-21 11:31:25 -05:00
/**
* Mocking `import.meta.url` and `got` here since they inevitably needs native ESM, but jest is sticking with CJS.
* Will figure out a way to run tests in native ESM mode.
*/
jest.mock('./src/connectors/meta-url.js', () => ({
metaUrl: 'file:///',
}));
jest.mock('../cli/lib/meta-url.js', () => ({
metaUrl: 'file:///',
}));
jest.mock('../cli/lib/commands/database/alteration/meta-url.js', () => ({
metaUrl: 'file:///',
}));
jest.mock('got', () => ({
got: {},
}));