QUnit: dummy test!
QUnit: dummy test!
I have a use case for running a 'dummy' test and not wanting the
result to be displayed: I want to delay running the test suite to
give the user a chance to select a particular module to run from a
list of modules.
Simple case:
test('dummy-delay', function(){
stop(3000);
return false;
})
Normally I would get this in the test results:
1. dummy-delay (1, 0, 1)
1. Test timed out
...
By modifying testrunner.js as follows, when test() returns === false,
the result is not displayed: in function test():
(function($) {
@@ -366,6 +372,7 @@
synchronize(function() {
config.assertions = [];
config.expected = null;
+ config.showResult = true;
try {
if( !pollution )
saveGlobal();
@@ -379,7 +386,8 @@
})
synchronize(function() {
try {
- callback();
+ config.showResult = !(false === callback());
+
} catch(e) {
if( typeof console != "undefined" && console.error &&
console.warn ) {
console.error("Test " + name + " died, exception and test
follows");
@@ -422,7 +431,10 @@
message: "Expected " + config.expected + " assertions, but " +
config.assertions.length + " were run"
});
}
+
+ if (!config.showResult) return;
+
var good = 0, bad = 0;
var ol = $("<ol/>").hide();
config.stats.all += config.assertions.length;