Thursday, October 1st, 2009
Category: jQuery
, Testing
<
>p
>There are many options for JavaScript Unit Testing but a “
de facto” standard for the
jQuery library, related plug-ins, and jQuery UI is
QUnit. Nothing new so far? Check this out:

According to tweets from John Resig the state of QUnit is:
- QUnit is now completely standalone (it no longer depends upon jQuery)
- QUnit now works outside of a browser (in Rhino, Spidermonkey, V8, JavaScriptCore, etc.)
- QUnit is now completely moved over to Github: http://github.com/jquery/qunit
The latest news is that QUnit is now a CommonJS/NarwhalJS package that can be installed using tusk ‘tusk install qunit’.
Thanks John for bringing some fresh air into JavaScript Unit Testing and Agile projects! I wonder if there is any plan to use QUnit via Fireunit as well…
- Ajax testing: Using available tools is key
Ted Husted is a business analyst, author, consultant, and speaker. His books include JUnit in Action, Struts in Action, and Professional JSP Site...
- On ASP.NET AJAX testing and debugging tools
Blogger Dan Wahlin is maintaining a list of Ajax automated testing and debugging tools. Many are free, and many cater to ASP.NET AJAX...
- Ajax app testing now available in Parasoft WebKing
Parasoft WebKing 6.0 helps Web developers plug holes in JavaScript through policy creation, strong unit tests and asynchronous HTTP message...
- Microsoft works on Ajax JavaScript tools
In a session at the recent Ajax Experience conference in San Francisco, Matt Gibbs, development manager in the UI Framework and Services team at...
- Ajax everywhere: Which framework to choose?
Writing and debugging Ajax, a JavaScript- and XML-driven development technique, can be difficult. In this tip, an expert introduces several frameworks...
Thanks for the write up, Andrea! I’ve been putting a lot of work in to QUnit these past couple days. Considering how many people use it I felt that it was important to make it more generic and less dependent upon jQuery itself. I definitely hope to have some more updates soon.
“QUnit is now completely standalone”
That’s a good thing, that’s why I choosed jsspec when I made my build process.
A testing tool with dependancies has very limited interest as the library you include may fix some bug in the tested code.
Still, from what I’ve understand (stop me if I’m wrong), QUnit is putting seems to put a lot of functions in the global namespace : init, module, test, expect, ok, equals, same, start, stop, reset, triggerEvent, done, log, testStart, testDone, moduleStart, moduleDone.
I meaned : “QUnit seems to put”
@ywg: Does that matter? I mean you don’t want global functions when your code is used in production but then you simply don’t include the qunit tests. On the test pages you want easy access to the test functions and the only way they can conflict if is your logic also has these global functions and then it’s poorly written anyway.
We use the qunit framework for our tests on the TinyMCE site it works very well and I love that it’s so easy to work with. Keep up the good work.
Let’s say you’re devellopping a component with a logger, and for whatever reason you end up in the global scope (scopes in javascript are quite tricky, this is a common source of bugs).
Your error may be occulted by QUnit’s log method.
@ywg: Just overwrite QUnit’s methods, no problem – and use the methods on the QUnit object directly: Qunit.ok, QUnit.equals (etc.)