Estoy tratando de probar un componente, aquí está el componente, simplificado:
const Block = () => { const { t } = useTranslation(); return <p data-testid="text">{t('some.text')}</p>; }Entonces tengo esta prueba:
test('That the text is correct', () => { const wrapper = render( <I18nextProvider i18n={i18n}> <Block /> </I18nextProvider> ); expect(wrapper.getByTestId('text')).toHaveTextContent('Hello!'); });El i18n es mi archivo de configuración, que se ve así:
i18n .use(Backend) .use(initReactI18next) .init({ fallbackLng: 'en', lng: 'en' debug: false, react: { useSuspense: false, }, interpolation: { escapeValue: false, }, });Pero todavía estoy recibiendo:
Expect element to have text content: Hello! Received: some.textMi sospecha es que el complemento Backend es lo que hace que no funcione.