Browserify Unit Testing

Time for the second part of the small unit testing guide that started with this post. In the first part, we’ve introduced a very basic function that calculated the age of a person based on a parameter that represented the year of birth. Before making the calculation, the parameter was checked to make sure it’s a number and if it wasn’t the function threw an error. Both use cases are small and perfect to have some test written for them so let’s begin.

Continue reading

Browserify Unit Testing

Returning to Javascript is always fun and scary at the same time. Lately I’m working on a web application and I wanted to make the experience less scary so I’ve invested some time to the tools that all the cool kids use, Grunt, NPM etc. Through this process I’ve discovered Browserify and I was so, so, so happy with the way it handles dependencies. At last I was able to divide my code in countless little js files. I had some fun with it until I’ve decided to add unit tests. I’ve already had some minor experience with Jasmine so I started messing around with Grunt to make it run my browserify-based tests. That’s when the hair pulling started.

Continue reading