score:4

Accepted answer

You can't directly render Routes, but a component with Router that uses routes inside. The answer you pointed to has the complete solution.

You will probably also need to change the browserHistory under test environment to use a different history that works on node. Old v3 docs: https://github.com/ReactTraining/react-router/blob/v3/docs/guides/Histories.md

As a side note, what's the point of testing Route which I assume is already tested in the library itself? Perhaps your test should focus on your route components: do they render what they should based on route params? Those params you can easily mock in your tests because they're just props.

I'm telling you this because in my experience understanding what to test was as important as learning how to test. Hope it helps :)


Related Query

More Query from same tag