Write Your Own Test Cases (2 Part Series)
Why Test Cases?
Writing test cases is one of those things developers at all levels seem to think is a good idea...but rarely ever make the time to do. In my experience as well, you can convince yourself very easily that your time and energy is better served tackling one more error or bug.
After going through a whole curriculum with the tests all written for you, switching over to a project with nothing to work with is a bit of a rude awakening. Sure, you can decypher errors fairly easily with some experience & familiarity, but having a quality functioning test suite is definitively more convenient 100% of the time (especially if you don't have to write it yourself!).
But, there is one more reason why learning this subject was something I felt was worth my time: I have a passion for teaching and educating people. Rather than walk people through some online coding lessons/challenges, wouldn't it be cool as hell to actually be able to teach them a few lessons that I wrote out myself entirely?
All Well and Good! But Where to Start!?!?
Good question! And one with no real answer! I mean, you should have an idea of what kind of tests you want to write first right? Maybe get a solid readme in place? Probably, but I jumped right into which testing frameworks were most practical for what I wanted to do. There are 2 testing programs that stood out instantly with a quick Google search: Mocha and Jest.
I had familiarity with Mocha as it was the primary testing framework at Flatiron, and it was a very comprehensive program. However, Mocha can be very intimidating with all the additional installs you have to do plus the additional code injected int your project. Jest, on the other hand, I had no experience with at all but stood out on how simple it was to get rolling. Zero experience plus easy set up? Jest was an easy choice for me to begin this part of my coding journey.
Part II I'll dive into my experience with the Jest testing framework, complete with pro's, con's, & how to's!