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 protected] 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 [email protected] 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).

Continue reading