In our Next.js app we use vinissimus/next-translate package for translations. We set it up accordingly:
next.config.js:
const nextTranslate = require('next-translate')
module.exports = nextTranslate()
i18n.js config file:
{
"locales": ["en"],
"defaultLocale": "en",
"pages": {
"*": ["en"],
"/": ["en"],
}
}
Using it inside the component with useTranslation hook:
const App = () => {
const { t, lang } = useTranslation();
return (
<Homepage>
<span>{t(`${lang}:homepage.title.header`)}</span>
</Homepage>
My question is how can I test it with jest with react-testing-library?
When I'm rendering my component in tests the translations do not work, only the key is returned. Also, I'd like to test it by getByText / findByText and passing:
{t(`${lang}:homepage.header`)}
How can I setup some kind of a wrapper or config for tests if I'm not using any i18nProvider in app but only this i18n.js config?