Ad

Tuesday, July 24, 2012

Testing your javascript with BDD

It seems like nowadays people that write javascript just hack the heck out the code and produce reams of code without testing it properly. I went about to try and correct my evil past ways and try and drive out my code with some behavior driven design. I used the Jasmine framework to write my tests which provides a nice GUI to see your tests running. This is what Jasmine framework is describes as:
Jasmine is a behavior-driven development framework for testing JavaScript code. It does not depend on any other JavaScript frameworks. It does not require a DOM. And it has a clean, obvious syntax so that you can easily write tests.
All you need to do it download the standalone version and cull out the existing files in 'src' and 'specs' directories (they are just examples), implement your test spec and add the source files to the SpecRunner.html and vwala you have a nice little JS test suite. Jasmine Documentation Reference Example Tutorial

No comments: