Since upgrading i18next to version 19.4.1, my Jest tests are failing (version of react-i18next: 11.3.4, using CRA 3.4.1):
You are passing a wrong module! Please check the object you are passing to i18next.use()
12 | import { initReactI18next } from 'react-i18next';
13 |
> 14 | i18n.use(initReactI18next)
The code starts as follows:
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
i18n.use(initReactI18next).init({
fallbackLng: 'en',
ns: ['translations'],
defaultNS: 'translations',
});
the check is: https://github.com/i18next/i18next/blob/master/src/i18next.js#L200 with initReactI18next = https://github.com/i18next/react-i18next/blob/master/src/context.js#L59
So the question is - what is initReactI18next in your case?
@yann-combarnous Can't reproduce it: https://codesandbox.io/s/react-i18next-gkv68?file=/src/i18n.js
Thank you for the quick turnaround. Found the root cause: a mock was added for "react-i18next" in common test utils. The interesting part is that until 19.4.1, I did not get above warning.
So this is a good thing it errors now. Apologies.
Sorry but can you please explain a bit more I am also facing the same issue. What exactly you mean by common test utils?
Most helpful comment
Thank you for the quick turnaround. Found the root cause: a mock was added for "react-i18next" in common test utils. The interesting part is that until 19.4.1, I did not get above warning.
So this is a good thing it errors now. Apologies.