My unit tests are failing due to the above issue.
//String.ts
import * as i18n from 'i18next'
import { initReactI18next } from 'react-i18next'
import BrowserLanguageDetector from 'i18next-browser-languagedetector'
import Backend from 'i18next-http-backend'
import languageMap from '@katal/localization/webpack-loader!'
i18n
.use(initReactI18next)
.use(BrowserLanguageDetector)
.use(Backend)
.init({
fallbackLng: 'en-US',
load: 'currentOnly',
detection: {
order: ['sessionStorage', 'localStorage', 'querystring', 'navigator'],
lookupQuerystring: 'locale',
lookupLocalStorage: 'locale',
lookupSessionStorage: 'locale',
caches: [],
},
backend: {
loadPath: (localeList: string[]) => languageMap[localeList[0]],
},
interpolation: {
escapeValue: false,
},
react: {
useSuspense: false,
},
})
The way I'm mocking this is :
const React = require('react')
const reactI18next = require('react-i18next')
module.exports = {
...reactI18next,
// this mock makes sure any components using the translate HoC or useTranslation hook receive the t function as a prop
useTranslation: (...args) => ({
...reactI18next.useTranslation(...args),
ready: true,
t: (tr) => tr,
}),
}
I'm import this in my App.tsx like
import './utils/Strings'
Some of the other links I checked are these and these but none of them work. Any help is appreciated on the workaround