And especially when we are working with advanced UI components, UI components that have things like advanced media that have canvases and graphs that is being animated. And we have a lot of micro-interactions and we also have a lot of gestures that we need to support, such as drag and drop or zooming and so on. This is where the mocking of the APIs are played really short. And it's sometimes very hard and you're just trying to make your fake DOM, fake browser work like a browser and you invest a lot of time and it's really frustrating in the test.
Because at the end of the day, it's very simple. When we have UI components, we want to test them in real browser. And this means that it will really render our component. We are not just going to test that we have the right CSS class, but we also want to test that the CSS is building our component correctly and it's actually correctly visualized. We want to talk about network call that is sometimes different when we are working with browser. We want to test the interaction, all the gestures that I mentioned, and also proper timing. When we are working with a mock, it usually does not conform to the timing that the browser really has, or pseudo event and so on. If there are side effects, again, pseudo event is one example, like input change and so on, we want to make sure that it's really triggered correctly, and not us manually triggering, and at the end of the day we might want to actually look at the component and screenshot it and do a visual regression test and make sure that it looks just like we expected it to look.
And over the years, there are a lot of tools that are supporting this kind of browser automation. They usually are a synonym of end-to-end tests, again from this approach, it's saying UI is only being tested in end-to-end. We have Selenium for 20 years now, we have WebDriver.io which is very popular. These are not the only ones. And recently, in the last few years, we have more modern tools like Puppeteer and Cypress, and just probably the latest and greatest addition is PlayWrite together with the newer version of Selenium. And we will discuss how they are different.
So, in order to achieve our second endpoint, we want to make sure that we test in a real browser. The third point for making this testing zen and fun, we want it to be efficient. We want to make sure that we write the test and that they run fast and easy to change and easy to do all the things that we need on top of them. And in order to understand how we can achieve efficiency, let's zoom a bit into the browser. This is what we know as the browser, but this is actually the rendering process of the browser. This is what we see on the screen. It has JavaScript, and now it has also workers. But under the hood, the browser has a lot of other processes like the one that you see here. We have the service worker process. We have network process. We have all the browser processes, things that control security, location, the inputs, getting the input from the operation system and sending it to the browser, and a lot of other parts. The first generation, or what was common in order to test the processes, was to actually run in the JavaScript process inside the browser.
Comments