Thursday, October 1st, 2009

QUnit – A JavaScript Unit Testing Framework

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:

  1. QUnit is now completely standalone (it no longer depends upon jQuery)
  2. QUnit now works outside of a browser (in Rhino, Spidermonkey, V8, JavaScriptCore, etc.)
  3. 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…

Related Content:

Posted by webreflection at 12:30 pm
7 Comments

+++--
3.6 rating from 47 votes

7 Comments »

Comments feed TrackBack URI

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.

Comment by JohnResig — October 1, 2009

“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.

Comment by ywg — October 2, 2009

I meaned : “QUnit seems to put”

Comment by ywg — October 2, 2009

@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.

Comment by Spocke — October 2, 2009

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.

Comment by ywg — October 2, 2009

@ywg: Just overwrite QUnit’s methods, no problem – and use the methods on the QUnit object directly: Qunit.ok, QUnit.equals (etc.)

Comment by JohnResig — October 2, 2009

Leave a comment

You must be logged in to post a comment.