So, the flows that if they don't work, the company loses millions per second. And only cover those business critical flows with end-to-end test. And then, let's be honest, not everything is possible to test. So, you still need to have a good observability on production. So, you should have metrics, you should have logging, you should track your events, like product events. So, you can immediately identify any abnormality if you deploy something wrong.
In this talk, we're gonna focus on steps one, two, and three. So, as I said, this talk is focusing on testing Node.js application. So, this is the architecture or structure of the typical Node.js application, how it works. You have a browser, you have some client-side application that runs in the browser. It makes a request. The request goes through some cloud infrastructure which does some things like HTTPS termination, maybe authentication, rate limiting, a lot of stuff. And then the request lands in your Node.js application. Let's say it's an express. So, you have a chain of middlewares which parses and enriches the request. Usually you have, I call them infrastructure middlewares. So, those middlewares that don't really belong to your application, but they just make it possible for your application to run in the environment. Yeah? So, they do a lot of things like parsing the incoming requests, like authenticating the user, maybe enabling localization, and so on and so forth. And then, finally, request arrives into the code, the white box, actually the code that you wrote, the code that contains the business logic. And this code needs to grab some data from somewhere to do some manipulations, yeah? So, it makes a bunch of API calls or maybe direct database calls. Those API calls are again going from some cloud infrastructure to APIs. And then when the data is back, you do something with this data, like you either return the JSON or maybe your server side render HTML and then you return to the browser. So, this is the type of application that we're gonna try to test.
If you write the unit test, you actually, with each unit test, you actually cover this tiny blue rectangle. I hope you can see it. So, you need to write a lot of unit tests to actually cover the whole white space. But still, you won't be able to cover the interaction between the boxes. So then, we can think how we can write integration tests that will help here. So, this is the typical scenario of the integration test. So, given we have some incoming request, HTTP request, for example, from the browser, application makes specified API calls and returns the expected response.
Comments