Sunday, October 5, 2008

QUnit and URL query string

QUnit is a really nice testing framework for JavaScript (jQuery's own framework - here's the tutorial I used).

I wanted to put some tests in the following URL:

but my tests weren't running - I kept getting:
"0 tests of 0 failed."
I learned that QUnit uses the URL query string to filter which tests to run, and in this case I don't want it to.

QUnit will run any test that has a substring-match with one of the query parameters. So "&foo&" in the URL will match tests "food" and "buffoon", and I guess this also means that the empty string will match anything. I appended a '&' to the end of the URL:

and now QUnit runs all my tests. Sweet!