Here is the my code looks like
export function myComponent(user: type) {
--------------
return (
<TouchableWithoutFeedback
testID="notificationCard"
onPress={() => navigation.navigate(NEW_ROUTES.profile, { id: rawId })}
>
<Card style={styles.stackedCard} ></Card>
<TouchableWithoutFeedback />
)
}
here I need to verify the function inside onPress I don't know what to do exactly but I tried this
test.tsx
const { environment, getByTestId } = renderWithNavigation(myComponent);
const notificationCards = getByTestId("notificationCards");
const notificationCard = getAllByTestId(notificationCards, "notificationCard");
fireEvent.press(notificationCard[0]);
expect(notificationCard[0]).toHaveBeenCalled();