In this episode, we dig into how to properly test user navigation between pages in an end-to-end test—something that's key for covering actual user journeys, not just isolated actions. We start by setting up a basic flow: adding a "Create Task" button that takes the user from the tasks list to a task creation page. You'll see how we refactor a standard button into a link, hook up the necessary route, and render the correct page.
Once that's working, we look at the right way to write a browser test for this interaction. Rather than just jumping straight to the target page, our test mimics real user behavior: visit the tasks page, click the button, and then check that the navigation worked as expected. Along the way, we hit some gotchas—like selectors versus link text, and being case-sensitive about those—so you get to see some quick troubleshooting.
A big emphasis is put on waiting for navigation to complete. We'll look at the difference between asserting immediately versus using waitForLocation
, and how you can customize how long you're willing to wait for the new page to load. Finally, we round out the episode by making some assertions on our new page and talk through how you can string together more steps to test much more complex user flows—think multi-step registrations or checkouts—by chaining page visits and interactions together. By the end, you'll know why it's so important to test flows, not just static pages, and how to handle navigation reliably in your tests.