Jest testing with actual translated text (jest, i18next) #3292
Unanswered
brightpixels
asked this question in
Q&A
Replies: 0 comments
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.
-
Hello,
I have the following basic buttoncomponent test:
Button.spec.tsx
I am getting the error:
Part of the problem is that I am mocking the
t
function which simply returns the translation key in jest.setup.jsReason for mocking the
t
function was to get around the error:console.warn react-i18next:: You will need to pass in an i18next instance by using initReactI18next
If I modify my test like this, it will pase:
expect(ButtonElment).toHaveTextContent("commonButtonLabel");
I want to be able to test with the actual translated text. Are there any examples of how to do this.
Beta Was this translation helpful? Give feedback.
All reactions