Skip to content

js unit testing follow up

I admit to being one of those people who has scratched their heads and said “javascript? How do you test it?”  What that meant to me, of course was “how do you automate testing?”

Certainly as my client side code has increased in complexity, I’ve moved towards more structured and repeatable ad hoc testing, driven by requirements and a test plan.  In some cases the win from automated testing was great enough for me to start to custom code some automated tests.

Long and the short of it, I’m evaluating javascript test automation and it’s starting to look good.

My first stop was qunit, which I’d heard about via jQuery.  I quickly ended up looking into screwUnit and jspec and yui and others.

James Carr had a useful round up of testing libraries which had me thinking either screwUnit or jspec would be good.  I like the ruby style of declaring tests … code.should_be(readable).  I don’t like learning new vocabularies (javascript tests should be written in javascript?)  screwUnit’s readme was more approachable for me so I started leaning that way.

This review was oddly helpful in narrowing me in one screwUnit as was this presentationThis email thread set me back a bit.

Late in the game I came upon jasmine, with a lot of what I liked about screwUnit plus good examples for spies, asynchronous and ajax testing.  Plus this evidence of responsive maintaniers.  So that’s where I’m starting.