Because lab 7 and lab 8 are similar, I’ve decided to combine post blog posts into one.
As with any piece of code we write, a good programmer always tests before releasing (I mean, you should be haha). As your program becomes more complex, you might fix a bug and unintentionally break something else. This is where
unit testing can save you! Unit testing is a style of coding which allows you to test a specific function and check it’s output with known data. For example: I have a function that returns
true if my email is valid. I know that
email@example.com is a valid email, thus my function will return true. But let’s say that a few months went by and I made a modification to the function which causes
firstname.lastname@example.org to return false. When I execute my unit tests, I will see that my new changes broke the email function.
There are many unit test design you can use but the one I’m familiar with is JUnit. For this lab, I will be using Jest (Which I’ve never used before).
The most “difficult part” was adapting to the Airbnb coding style. Everyone has their own coding style but with most programming jobs, you are “forced” to adapt to the company’s coding style. Even though this might not be as difficult as you think, it actually took me longer than it should haha.
Always have a form of unit testing. This will help you create a more stable and uniform program 🙂