Text content not updating after i18n.changeLanguage() in React Testing Library test #2317
Unanswered
tuboihirokidesu
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Maybe I'm not the right person to help with that, but what's the value of ctx.locale in the getServerSideProps function during the test? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm having an issue with i18next language switching in my React Testing Library tests. While the translation function (
t()
) correctly returns the English text after switching languages, the actual rendered content remains in Japanese.Here's my test code:
The component implementation:
i18n test setup (f you don't mock it, the keys of the translation dictionary (JSON) will be rendered.):
Test utils setup (custom render):
The test fails with:
While
i18n.t()
correctly returns the English translation after language change, the component's content doesn't update. I've tried adding a delay withsetTimeout
, but it didn't help.Any suggestions on how to properly test i18n language switching with React Testing Library?
Beta Was this translation helpful? Give feedback.
All reactions