I have a component
export function Component() {
const route = useRoute<RouteProp<StackParamList>>();
const amount = route.params.amount
return (<View> <Text>{amount} is now</Text></View>)
}
and my test is very simple but it fails, I am just checking if the text is rendered.
test('should display amount', () => {
const screen = renderWithWrapper(
<Navigation>
<Component />
</Navigation>
)
expect(screen.queryByText(/is now/))
})
The code fails here const amount = route.params.amount
says TypeError: Cannot read properties of undefined (. reading params).
I guess my question is how do I mock the useRoute to receive the amount
params??