Closed amir-deriv closed 5 months ago
This could also be my problem right now.
jest: 29.7.0 @testing-library/react-hooks: 8.0.1 react: 18.2.0 react-dom: 18.2.0 node: 18.19.1 yarn: 4.0.2
[edit]
nvm I see i have to upgrade to @testing-library/react
Update:
It was my wrapper
which was causing the issue :)
I was returning the null
inside my Provider (wrapper) if the values are not loaded.
if (!i18nInstance || !isTranslationsLoaded) return null;
I fixed it by using await waitFor(() => result.current.localize)
vitest
: 1.3.1@testing-library/react
: 14.2.1react
: 18.2.0node
: 18.16.0npm
(oryarn
): 9.5.1Relevant code or config:
useTranslations.ts
What you did:
I am trying to write test cases for this hook
useTranslations
, but I always get the result fromrenderHook
as{ current: null }
What happened:
Problem description:
I am trying to test the hook
useTranslations
, but I always get the result asnull
. I have tried adding logs into the function body ofuseTranslations
and the values are logging just as fine. The only problem is whatever I am returning I am not getting in the result key ofrenderHook
and it's always returningnull
I am using
vitest
andreact@18
and@testing-libarary/react@14
sorenderHook
is coming from the testing library.Can anyone help me identify what could be the issue here ? Thanks