RealOrangeOne / react-native-mock

A fully mocked and test-friendly version of react native (maintainers wanted)
MIT License
571 stars 153 forks source link

How to access elements inside <TouchableOpacity .. /> ? #82

Closed romanlv closed 8 years ago

romanlv commented 8 years ago

I'm trying to test a simple component, where some areas are wrapped with

          <View style={styles.fieldContainer}>
            <TouchableOpacity onPress={() => {onPressHandler(...);}}>
              <IXText text={inputTime}  />
            </TouchableOpacity>
          </View>

I've tried different methods and rendering functions, it only can find/traverse to TouchableOpacity element, but not children inside it? Is it a problem of react-native-mock or enzyme?

Any ideas on how to test this component?

RealOrangeOne commented 8 years ago

I believe this is a duplicate of #76. See there for more.

romanlv commented 8 years ago

Well, somehow it works for <View> elements, you can wrap TextInput with <View> (with multiple levels) and the whole pack will be rendered by the shallow function. Can it just reuse the same logic for TouchableOpacity (and similar advanced containers)? For the tests it will be useful to "see through" those system elements...