Increase QUnit.config.testTimeout to 30s
[lhc/web/wiklou.git] / tests / qunit / data / testrunner.js
index 50e89da..96a88f0 100644 (file)
@@ -26,9 +26,9 @@
         */
 
        // When a test() indicates asynchronicity with stop(),
-       // allow 10 seconds to pass before killing the test(),
+       // allow 30 seconds to pass before killing the test(),
        // and assuming failure.
-       QUnit.config.testTimeout = 10 * 1000;
+       QUnit.config.testTimeout = 30 * 1000;
 
        // Add a checkbox to QUnit header to toggle MediaWiki ResourceLoader debug mode.
        QUnit.config.urlConfig.push( {
                                        // As a convenience feature, automatically restore warnings if they're
                                        // still suppressed by the end of the test.
                                        restoreWarnings();
+
+                                       // Check for incomplete animations/requests/etc and throw
+                                       // error if there are any.
+                                       if ( $.timers && $.timers.length !== 0 ) {
+                                               // Test may need to use fake timers, wait for animations or
+                                               // call $.fx.stop().
+                                               throw new Error( 'Unfinished animations: ' + $.timers.length );
+                                       }
+                                       if ( $.active !== undefined && $.active !== 0 ) {
+                                               // Test may need to use fake XHR, wait for requests or
+                                               // call abort().
+                                               throw new Error( 'Unfinished AJAX requests: ' + $.active );
+                                       }
                                }
                        };
                };