Skip to content

Instantly share code, notes, and snippets.

@tanner-west
Created April 14, 2022 01:35
Show Gist options
  • Save tanner-west/217a890ef13cfb59fe13a018772b6d17 to your computer and use it in GitHub Desktop.
Save tanner-west/217a890ef13cfb59fe13a018772b6d17 to your computer and use it in GitHub Desktop.
// 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&#39;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