I use useFocusEffect from @react-navigation/native and I try to test the component. I tried what @meshantz suggested on react-navigation-hooks: How to test useFocusEffect but when I run the tests it says Cannot read property 'Provider' of undefined.
Can you please explain what I am doing wrong? I'm new to testing in react-native and can't seem to find a solution.
Hard to say without seeing your test file, but if you're getting that error then check you've imported
NavgationContext
:Also confirm that your file has a
tsx
extension and that you have@react-navigation/native
in yournode_modules
folder andpackage.json
.