Recently, in the last 2 months or so since I graduated from Flatiron School, I've been looking for ways to push myself to continue to grow. At first, I wanted to try my hands at building larger side projects but found that to be very draining in addition to a job search and family life. So I've been pushing myself in new, smaller yet extremely meaningful ways. One of those ways was to teach myself how to write my own test cases, specifically for JavaScript.
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.
Next Time on JavaScript Testing Z!
Part II I'll dive into my experience with the Jest testing framework, complete with pro's, con's, & how to's!
Top comments (0)