Created
April 14, 2022 01:35
-
-
Save tanner-west/217a890ef13cfb59fe13a018772b6d17 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Consider an app with the following two components | |
const HeadingComponent = (props) => ( | |
<Text style={{fontWeight: 'bold'}}>{props.title}</Text> | |
); | |
const DebugComponent = () => { | |
return ( | |
<> | |
<SafeAreaView> | |
<ScrollView> | |
<HeadingComponent title='My Debug Component' /> | |
<Text>Please test me</Text> | |
<Button title={'Click this button'} /> | |
<Text>While you're here, click the button ๐</Text> | |
</ScrollView> | |
</SafeAreaView> | |
</> | |
); | |
}; | |
// In an Enzyme test, we might do the following... | |
const wrapper = shallow(<DebugComponent />); | |
console.log(wrapper.debug()); | |
// ...and see this output | |
/* | |
<Fragment> | |
<ForwardRef(SafeAreaView)> | |
<ScrollView> | |
<HeadingComponent title="My Debug Component" /> | |
<Text> | |
Please test me | |
</Text> | |
<Button title="Click this button" /> | |
<Text> | |
While you're here, click the button ๐ | |
</Text> | |
</ScrollView> | |
</ForwardRef(SafeAreaView)> | |
</Fragment> | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment