Root-App / react-native-mock-render

a fork of react-native-mock that renders
MIT License
85 stars 50 forks source link

Enzyme output #32

Closed untemps closed 6 years ago

untemps commented 6 years ago

In my unit tests, I used to render the components using the Enzyme shallow() function. The output printed by debug() looked like a regular tree component:

<TouchableOpacity accessibilityComponentType="button">
   <View style={{...}} onLayout={[Function: bound onViewLayout]}>
      <Image source={{...}} style={{...}} />
   </View>
</Component>

Using react-native-mock-render and jsdom, the tree nodes are not named anymore:

<Component accessibilityComponentType="button">
   <Component style={{...}} onLayout={[Function: bound onViewLayout]}>
      <Image source={{...}} style={{...}} />
   </Component>
</Component>

Is it intentional and how can I retrieve each node using the find() function in this case?

dabit1 commented 6 years ago

I'm running in the same issue. Is it an expected behavior? If it is, for instance, it means that I can't use find('TextInput') :-1:

dabit1 commented 6 years ago

@untemps Ey man, I have created a pull request to fix it! #39

bob-carson commented 6 years ago

Hi all, thanks for posting this issue! You should be able to work around this in the short term by finding components by their testID.

I'm happy to help get code changes merged to help address this issue as well. @dabit1, I can reopen that PR for you if you update it to resolve the errors that @mbutsko pointed out.