I currently working on adding jest unit test for the react-navigation, for example: My StackNavigator
const Nav = StackNavigator({
Home: {
screen: Home,
},
Second: {
screen: Second,
}
});
export default class App extends Component<{}> {
render() {
return (
<Nav/>
);
}
}
My Home component
export default class Home extends Component<{}> {
_goToNextPage = () => {
this.props.navigation.navigate('Second');
}
render() {
return (
<View>
<Text>Home</Text>
<Button
onPress={this._goToNextPage}
title="Go to Second Page"
>Click to next page</Button>
</View>
);
}
}
My Second component export default class Second extends Component<{}> {
render() {
return (
<View>
<Text>Second</Text>
</View>
);
}
}
How should I write jest unit test to test "when I click the GoToNextPage button, and the Second Component should be rendered correctly ?"
I do not find any useful info about jest with react-navigation, Any help will be much appreciated!!!
Thanks a lot~