DEV Community

Discussion on: This week I learned: How to mock a Render Props Component in React

Collapse
 
betofrega profile image
Beto Frega

Better yet: instead of using jest.mock, pass the component you wish to mock as a prop to the component under test and give it the default value of the actual component implementation. While testing, pass the mocked component as a prop to the component under test. Dependency injection is usually better than under the hood mocking.