So, we know we are not going to create monoliths in our production code when we're writing it all out before it goes into our built system. So don't do it when you test environment.
Split up your tests Every good presentation is a good meme, right? Split up your tests. If you're testing small modular parts, split it out. Make sure that you can run each and every test individually, just like you would if you were splitting out your production code, right? People go, yeah, yeah, I can split out my code. I know how to break this down, right? You say the same for tests and they're like, it's a test, why does it matter? It does. It really, really does.
And this is why we need to get into this mindset of kind of like, whenever you're writing code, you're writing code, be it an automated test or production code, right? Or anything in between. Code is code. Your esthets are engineers. They write code. Your software engineers, they write code. They're exactly the same. They look at the problems slightly differently, but they still look at the problem. And so it's important that we make sure that when we're breaking these things down into the individual parts, that we do so in a meaningful way.
So we've talked about this, where we have our unit tests, our service tests, but that big, bulky UI part, we can break that down even further. We don't need a full end-to-end test for our UI tests. Yes, we might need a browser, and it's important to make sure that we test in all browsers that our users use. If you're going to test in Chrome, test in Chrome, Chromium is going to react slightly differently. So if you test in Chromium, you're not always going to get the same end experience than an edge user would, or a Chrome user would, or a Brave user, or an Opera or Vivaldi, right? It's all the same browser under the hood for the engine, but not always going to give you the same result when you're moving things about because of the way they configure it and ship it. Same with using WebKit. WebKit might be the underlying tool and engine for Safari, but there are times where Safari will act very differently to WebKit, and it will act very differently to iOS Safari. So always make sure that when we're breaking these down, that we break them down, and then we test where our end users are going. Because that way, we can know that we've done the right job.
Now, by splitting out things into these slightly more manageable parts, we are going to remove flake. The smaller you make your tests, the less flaky they will be. Now, I'm sure you've all tried to write end-to-end tests, and a lot of the times, you need to align a lot of stars to make it work. Your database needs to be set up, your middleware needs to be set up, your front end needs to be working, and whenever you do something, it needs to be able to pass through all these layers and then back again. And being JavaScript, everything is asynchronous. So you need to align a lot of stars to make things work.
Comments