It's one thing to have a test failing, and maybe your test doesn't make sense, and you don't understand it, but at least you know that something's wrong, right? It's much worse when you don't have any test failures, because you don't have all the right tests, and you don't understand what's wrong at all. We don't know when the problem was introduced in this case, and instead, it would have been great if we had some tests to catch it.
This brings me to my first lesson. We could write the test now. Now that we know that there's an issue, we could write a test for this functionality that was broken, but when should we have written those tests? When was the ideal time to have written them and then have them going forward? Let's talk about TDD. TDD is where we write our tests first. And this can be cool, because if we write our tests first, there's this notion in TDD where it kind of designs the architecture of our application and how we're going to implement things. And TDD is great when we know two things. We know what we need to write, and we know where those things we need to write should go. To know those two things, it helps to have well-established patterns and frameworks that rarely change, a set way of doing things that we're accustomed to.
That's not front-end in 2024. I think we have the most competitive landscape yet for frameworks and libraries. And that's a good thing. That's pretty cool, actually. I've worked on a few different projects in the last year, and all of them have had maybe like two or three different frameworks and then a handful of different libraries. Things are implemented in different ways, on different projects, all the time. If you go from one company to another, you could be looking at two very different architectures.
So, yeah, knowing where to put everything at the outset and using tests to guide that, see, that's the thing. You need to know where things are going to go to know where you're going to write your tests. And that's just not great. TDD, front-end, I don't think they mix. I've always had trouble with it. So let's talk about what the alternative is. Testing last isn't great either. Who has heard someone say this? The feature work is done. I just need to write the tests. I have said this at stand-up. I've heard others say this at stand-up. This isn't great, either. Waiting till the end is just making tests into a chore.
Comments