0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-06 20:40:08 -05:00
logto/packages/experience/src/jest.setup.ts
Gao Sun d203c8d2ff
refactor: experience ssr (#6229)
* refactor: experience ssr

* refactor: fix parameter issue
2024-07-12 19:00:36 +08:00

24 lines
794 B
TypeScript

import { type LocalePhrase } from '@logto/phrases-experience';
import { ssrPlaceholder } from '@logto/schemas';
import { type DeepPartial } from '@silverhand/essentials';
import i18next from 'i18next';
import { initReactI18next } from 'react-i18next';
// Simple resources for testing
const defaultI18nResources: DeepPartial<LocalePhrase> = {
translation: { action: { agree: 'Agree' } },
};
export const setupI18nForTesting = async (
enPhrase: DeepPartial<LocalePhrase> = defaultI18nResources
) =>
i18next.use(initReactI18next).init({
resources: { en: enPhrase },
lng: 'en',
react: { useSuspense: false },
});
void setupI18nForTesting();
// eslint-disable-next-line @silverhand/fp/no-mutating-methods
Object.defineProperty(global, 'logtoSsr', { value: ssrPlaceholder });