Summary
This chapter has shown you how to use React Router in a testable fashion. You have learned how to test-drive the Router
, Routes
, Route
, and Link
components. You have seen how to use the React Router useSearchParams
and useNavigate
hooks.
Most importantly, you’ve seen that because routes give an extra level of entry into your application, you must split your existing navigation tests into two parts: one to test that a link exists (or is followed), and one to check that if you visit that URL, the right component is displayed.
Now that we’ve successfully integrated one library, the next one shouldn’t be too tricky, right? In the next chapter, we’ll apply all the skills we’ve learned in this chapter to the integration of another library: Redux.