Sometimes we as developers miss the most obvious errors. Sometimes we know about them and say "we'll come back to it". Then it's time to deploy the website or do a demo for a client. They go to pull up the website and they're promptly greeted by an ugly looking server error message. Do you remember that thing you forgot now?
That's where testing comes in. It's like your best friend that keeps you from looking stupid in front of the people who pay you. Although just like a best friend, it can be easy to take it for granted because it's always there. (go tell your friends thank you) To drive home why it's important to test code, here's a list of some things your testing saves you from.
There's nothing worse than getting everything to work locally and then making the website live and nothing works like it should. When your client's money is on the line, they don't care if you got the website to work on your machine. They want it to work on their customers' machines.
You can avoid this by deploying the website earlier and doing some testing yourself. There might be a connection string or a CORS policy that doesn't have the right value. This is also a chance for you to make functionality checks. Users aren't going to know the little tricks you do to make the website work. Make sure they don't need to.
Even if deploying early takes a little extra time, it'll be worth it. Not only will you be able to make quick fixes to any glaring bugs you find, but you'll be able to show off the real quality of your work.
Having multiple clients, projects, or roles stretches your time thin so you need to make sure you're using it as effectively as you can. At first it seems like testing takes too much time, especially when it comes to those super small unit tests. Make the time for them.
It's easier to trace a bug when you're working on a specific chunk of code than when you have to look through the whole application. Errors have a tendency to propagate and if you have anonymous functions it's normal to get lost in the call stack. That's why unit tests are important.
They let you look at the smallest things to make sure they work right under multiple scenarios. You know how users can find ways to break your code, so you do it before they get a chance to. It'll save you time in complaints, digging through code under pressure, and dealing with other people looking over your shoulder.
Testing your code teaches you how to write good code because you have to fix all of your bad code. When you have to go through and fix your own bugs you learn different ways to solve problems. The number of ways you can break code is immeasurable and that's what makes it so interesting.
Finding and fixing errors helps you know what to look out for when you write your code in the first place. That's how you get experience as a web developer. You write code and fix it. The more testing you do, the more exposure you'll get to different kinds of bugs.
The more bugs you see, the more you'll stop writing them. Therefore, you'll become a powerful developer. Testing is the teacher that you'll hold onto for your entire career because you learn so much from it. Even if you don't feel like learning.
Now that's not to say testing saves you from everything. There might be issues with the server that you have no control over or a browser update might cause some issues. Despite that, testing is important to save you from the common issues you run into or those things you forgot to "come back to".
So please don't skip testing. It's not just for you, but for the developers who have to work on your code after you. No matter what the stereotypes are or what society says, web development is something you do with other people. Testing makes your life easier and other people's lives easier. Do it because it's right. :)
When you see the next article, brace yourself. I'm going to be doing my first web series! You'll get to learn about How Your Website Comes Together. While you wait for that, you can go check out my free web development email class. You can click here to sign up
(open source and trusted by devs everywhere ❤️)