Transcript
00:00 One of the most common mistakes developers make is they think that an end to end test has to run the entire application as is, without changes. In that line of thinking, they actually describe a useful kind of test, but it's called a smoke test, and its purpose is different. It'll be running continuously against your production system and monitor its health. And it won't be running all the hundreds user flows that exist in your app. That would be terribly inefficient.
00:24 When it comes to end to end tests, however, despite them involving the majority of your app, they still are controlled tests, and they run-in a controlled environment, the one we spend so much effort to prepare, working on the test setup and making sure that no unexpected side effects or dependencies can influence the results of our end to end tests. And what is the most common side effect on the web? It's the network request. And while we want our clients to communicate with a server, drawing the line somewhere around the database level, requests to third party services are a hard no. Because you're not in charge of those services, and you cannot afford the runtime influencing the results of your end to end tests.
01:02 Instead, you want to focus on how your application performs given the state of those third party services, which brings me to the topic of this exercise. Because while you were gone, I've made a few changes to the app. In particular, I've added this location field over here so the users can now associate their notes with locations in the real world. For example, I can choose San Francisco if I wanna have a note about my vacation there. And to get the list of those locations, our app is requesting them from a third party service, client side, so it can be performant, debounced, cached, and so forth.
01:33 But that poses a problem. If that location service is down, our end to end test will start failing because they cannot complete, they're not getting the data to display in the UI. This is where we can reach out to API mocking to help us out. And that's exactly what you will be doing in this exercise. You will use a tool called mock service worker in conjunction with Playwright to intercept those third party requests and mock their responses in end to end tests.
01:56 You'll be able to reproduce the exact locations you want so they are fixed every time your test runs, and then assert that the user can actually create the node associated with those locations. So give it your best, and see you once you're done.
