Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

387
Visualizações
React Testing Library - i18n translations not working

I'm trying to test a component, here's the component, simplified:

const Block = () => {
   const { t } = useTranslation();
  
   return <p data-testid="text">{t('some.text')}</p>;
}

Then I have this test:

test('That the text is correct', () => {
  const wrapper = render(
    <I18nextProvider i18n={i18n}>
      <Block />
    </I18nextProvider>
  );

  expect(wrapper.getByTestId('text')).toHaveTextContent('Hello!');
});

The i18n is my config file, which looks like this:

i18n
  .use(Backend)
  .use(initReactI18next)
  .init({
    fallbackLng: 'en',
    lng: 'en'
    debug: false,
    react: {
      useSuspense: false,
    },
    interpolation: {
      escapeValue: false,
    },
  });

But I'm still getting:

Expect element to have text content:
   Hello!
Received:
   some.text

My suspicion is that the Backend plugin is what's making it not work.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda