react-navigation/react-navigation.github.io

More examples and documentation for Testing with Jest

loekTheDreamer opened this issue · 0 comments

Couldn't find a route object. Is your component inside a screen in a navigator?

      15 |   const {
      16 |     params: {title},
    > 17 |   } = useRoute<RouteProp<RootStackParamList, typeof SMART_CONTRACT_DETAILS>>();
         |       ^
      18 |
      19 |   const {errors, handleBlur, handleChange, handleSubmit, touched, values} =
      20 |     useForm(submit);

This error doesn't help me solve anything. i have added the navigator like it has suggested.

describe('<SmartContractDetails />', () => {
  it('should render as expected', () => {
   render(
      <NavigationContainer>
        <SmartContractDetails />
      </NavigationContainer>,
    );
  });
});

Please can you add some actual examples of how to test features. like passing params and using the navigator.