D
D
Dmitry2019-05-07 22:56:16
Test Driven Development
Dmitry, 2019-05-07 22:56:16

How to test react component with routing using Enzyme?

Testing a react component with enzyme. I call the mount function for deep rendering.
const component = mount(MyComponent)
But firstly, the application uses the redux store, and secondly, one of the children has , respectively, the react swears that the link can only be inside the router and that to use the store you need to wrap it in a provider. After the wrapper, it is not clear how to find the component itself in the returned value in order to call any of its functions and / or re-render. At least returns an object with length = 0 What is done in such cases? <Link />component.find(MyComponent)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2019-05-07
@dimoff66

React Router: Testing
Redux: Writing tests. Connected Components

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question