-
Notifications
You must be signed in to change notification settings - Fork 35
Recommended way to provide NavigationContext for testing #16
Comments
Hi, You can check this react-navigation/rfcs#75 (don't hesitate to comment RFC if this is useful to you) |
Awesome thanks! That seems a lot nicer. We're using enzyme and shallow rendering and I tried your But ya I'm all for a |
Closing as I figured out a solution (and gave up on enzyme and shallow rendering it): react-navigation/rfcs#75 (comment). Feel free to steal it or cherry pick it for docs if it seems useful. Hopefully the RFC will result in a built in |
It's also possible to use import { NavigationProvider } from '@react-navigation/core';
mount(
<NavigationProvider value={navigationMock}>
<SomeScreenYoureTryingToTest />
</NavigationProvider>
); |
I'm shallow rendering a component that uses
useNavigationParam
and gettingTypeError: Cannot read property 'getParam' of undefined
. Is there a recommended way to provide NavigationContext for testing (I'm using Jest)? I used to just pass a fakenavigation
prop but that won't be passed to NavigationContext.The text was updated successfully, but these errors were encountered: