Conditionally Skip Tests

Conditionally Skip Tests

In the project I'm working on, there is a bunch of code specifically to test IE. We want to be able to unit test this code and have those tests run on IE, but they would fail if run on other browsers.  I wanted to get people's thoughts on how this could be better supported by QUnit.

Right now I believe the only real option is to add an if statement within the test (or split the IE tests into a separate HTML file and just know to not run that particular file, but that doesn't work easily with continuous integration servers).

What I'd like to achieve is something semantically equivalent to:


test("Selection of element containing text", function() {



Obviously Java style annotations aren't going to work with JavaScript, but the key features being:

1. Really simple to flag a test.

2. Really obvious that the test is run conditionally.

3. I'd envision the @IEOnly to be a user-definable condition.  This would allow you to skip tests that can't work when run from a file:/// URL or in browsers that don't support canvas by defining your own condition. It could even be something like @SlowTest so that slow tests only run on the nightly build but not on every commit.

I can spend some time developing this functionality but wanted to get suggestions on how the API would work and check if it's of interest first.


Adrian Sutton.