You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, both of them are saying that it's simply because Jest is outdated. This is not my case since I'm running the latest version of Jest at the moment which is 29.2.2. I'm also using ts-jest and it too is up to date, version 29.0.3
I've tried the other approaches that suggest to mock useTranslations hook, however, this does not work for me since I need to have the translations in the code and not only the translation keys.
I've deleted most of my translations files, in public/locales/en I only have one file for the example but in my project I have a bunch of them.
sorry, no idea.... (looks to be out of i18next scope)
you may try to create a minimum reproducible example...
just the most necessary parts to reproduce the issue
Thank you for getting back, indeed, the problem isn't with i18next, it was with Jest. In case someone ends up with the same issue as me here's what was happening.
I have a project in Typescript but some config files are in JavaScript and Jest needs to load these config files. I'm using ts-jest to transform Typescript files but I was missing babel-jest to transform JavaScript files.
The I only needed to add '^.+\\.js$': 'babel-jest', to transform and it fixed my problem.
馃悰 Bug Report
I'm using
react-i18next
in my App and I have not issues with the translations. However, when doing tests following this guide: https://react.i18next.com/misc/testing#testing-without-stubbing.I'm getting an error: TypeError: Cannot destructure property 'config' of 'cacheKeyOptions' as it is undefined.
I've searched for this type of error and found these two issues:
https://sebastian-rogers.medium.com/cannot-destructure-property-config-of-cachekeyoptions-as-it-is-undefined-f31b383abf5c
callstack/react-native-testing-library#743
However, both of them are saying that it's simply because Jest is outdated. This is not my case since I'm running the latest version of Jest at the moment which is 29.2.2. I'm also using
ts-jest
and it too is up to date, version 29.0.3I've tried the other approaches that suggest to mock
useTranslations
hook, however, this does not work for me since I need to have the translations in the code and not only the translation keys.I've deleted most of my translations files, in
public/locales/en
I only have one file for the example but in my project I have a bunch of them.This is a Create React App V4 that I've ejected.
To Reproduce
Here's a codesandbox example
// Paste your code here
Expected behavior
I would expect Jest to be able to import the
i18next
instance to provide translations in my testsYour Environment
The text was updated successfully, but these errors were encountered: