A few months back someone posted a suggestion on QUnit for the inclusion of a “skip” feature. The idea, as far as I remember, was to highlight a test that wasn’t developed yet and allow the use of conditions to identify a given feature in a browser (and keep highlighting the test).
In the end of discussion the issue was denied for landing into the core and a suggestion was made for the creation of a plugin.
A pending test is really useful because it allows the use of TDD over distinct parts and the easy differentiation of what is being implemented but failing and what is not implemented yet, besides it serves as a flag for non deterministic tests in a production environment. Even every test framework I know implements some “pending” feature for that purpose.
A feature detection API inside QUnit is not a good idea. It encourages the use of complex conditions in an environment that should be clear and precise. Besides it is out of the scope of QUnit.
Still you should take care when developing a test in Javascript. Some times a beginner developer tries to do something more dynamic and ends up turning your suite into a spaggetti.
Some practices could be done to avoid that to happen when working feature detection in Javascript:
Use feature detection as a first statement inside a test
Always check if a browser does not support a given feature to test it, otherwise create a default passing assertion with a simple description.
Always use “expect()” in the beggining of a test declaration
QUnit team is planning to deprecate the use of expected as a second argument of a test. Therefore you should always use the “expect(x)” as a first statement in a text, if feature detection is required you should put just below the condition.
Do not test more than necessary
Do not exaggerate in the assertions. A test should check an specific funcionality and be clear in the description
The result would something like:
test( "Testing key filtering", function() {
if ( !Object.keys ) {
ok( true, "Unsupported Browser" );
}
expect( 3 );
...
});
Of course, you could use Modernizr or extend QUnit to implement similar functionality. But if you want something fast and that have a considerable efficiency this model is something to get started. Maybe even document in the style guide of your company to avoid diversion by the other employees.