mardi 2 juin 2020

Check if navigation.navigate is called in react native testing

I've been using 'react-test-renderer' for testing react-native, Mostly on it's functions. Lately I've found out that there is a testing library for react-native which is @testing-library/react-native. What I wanted to do is to check if navigation.navigate or alert has been called in a function. I don't know which of these libraries can achieve that and how.

onSubmitPress = () => {
  if (true) {
    this.props.navigation.navigate('MainPage');
  else { 
     showAlert( "Not Allowed);
  }

Aucun commentaire:

Enregistrer un commentaire