Suppose I have this component:
import React, { Component } from 'react'; import { Text, TouchableWithoutFeedback, View } from 'react-native'; class MyComp extends Component { onRowPress() { this.myCoolFunction(); } myCoolFunction() { console.log('hi'); } render() { return ( <TouchableWithoutFeedback onPress={this.onRowPress.bind(this)}> <View> <Text>Hello World</Text> </View> </TouchableWithoutFeedback> ); } } export default MyComp;
How can I simulate 1 click on “TouchableWithoutFeedback” and make sure that “myCoolFunction” is called exactly 1 time?
If this is not necessary, then I would prefer not to add more dependencies except for "reaction-dom" and "reaction-addons-test-utils".
I have seen many manuals claiming this and this, but I'm afraid that they are out of date, and I want to make sure that I don’t go through any unnecessary workarounds and bloat my code.
I have a joke / reaction / reaction to the native in their latest versions.
Edit: The Jest Official Documentation says that DOM tests can be run either with Enzyme or with TestUtils . How can I accomplish this with TestUtils?
reactjs testing react-native jestjs
Tsury
source share