|JSNUnit||script.aculo.us unit testing|
So apparently there are people that are trying to solve this problem, but how do you choose between all of these frameworks?
I chose JSSpec because it uses the behavior driven development terminology that I’ve become accustomed to recently. Screw-Unit also is BDD-based but it didn’t seem to be as straight-forward. QUnit is a newer framework that was originally designed by the jQuery folks as a framework for testing jQuery. I used QUnit on a real project for a client and it got the job done. QUnit seems to be the most talked about of the frameworks just because people find it when their on the jQuery site. (FWIW, QUnit doesn’t have any integration with jQuery that makes it any easier to use than the others.) YUI Test is used with the Yahoo UI framework, so if you’re using the YUI framework, YUI Test may be a good fit for you. People that use YUI Test seem to have a lot of good things to say about it.
I noticed that the JS testing tools you’ve chosen seem to be browser based. I developed RhinoUnit specifically for running from the command line so it can be easily incorporated into cruise, or whatever continuous integration tool you use.
I agree with your observation about mocking in JS, but there are a few things that can be useful. RhinoUnit provides a ‘function that must be called’ to ensure that your code does actually call something. It also checks for variables that accidently make it into the global namespace.
Anyhoo, we’ve found it quite useful, and I’d be open to any suggestions about how to make it better.
Thanks for the tip, I’ll have to check that out.
JSpec is my fav by far, looks way better, and has way more matchers