In this episode, we take a basic test and turn it into a more realistic example by focusing on authenticating users—because let’s be honest, most of our testing is for logged-in users! We start by renaming our test to something more purposeful, like a dashboard test, and set out to check if the logged-in user’s name actually appears on the dashboard screen.
Next, we go over how authentication works in end-to-end (E2E) tests compared to more traditional feature tests in Laravel. Instead of using actingAs
, we use loginAs
inside our browser automation, which handles the browser-based login process for us. We walk through updating the Vue dashboard component to actually show the current user’s name (making the test meaningful!), and do a manual registration in the app to make sure everything's wired up end-to-end.
The episode then highlights the differences in APIs for feature tests versus E2E tests: instead of sending HTTP requests, browser tests interact with the interface like a real user would—clicking buttons, visiting pages, and so on. We write a simple assertion to confirm that the authenticated user’s name is shown with a “Hey, UserName!” message.
There's a quick chat about test brittleness—like depending on specific text that might change—and why that's something to watch for as you write more robust tests. Then, we finish up by running the test (success!) and using the browse
option to visually see what’s happening in the browser, which can be a lifesaver when diagnosing sticky test issues. We’ll rely on this visual debugging trick more as the course continues!
All in all, this episode is all about getting a realistic, authenticated workflow set up for E2E browser tests and seeing how to actually interact with a real app as a real user would.