This is designed as a simple React
component mock to be used with Jest
, that still presents enough information to be useful in a Snapshot test. It's handy when you either don't want to shallow render, or are unable to.
To use this mock, insert the following into your test file, to mock the sub-components, substituting out the names:
jest.mock("../MyComponent", () => ({ MyComponent: (props) => mockComponent("MyComponent", props) }));
This will render a string output useful for snapshot testing.
≤MockMyComponent
name=foo
emptyProp=null
complexProp={"name":"This is a Complex Prop","key":"0001"}
/≥