Merge "QUnit: Detect unfinished jQuery effects or ajax requests in teardown"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 11 Jul 2014 21:15:47 +0000 (21:15 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 11 Jul 2014 21:15:47 +0000 (21:15 +0000)
tests/qunit/data/testrunner.js

index 50e89da..f3f884a 100644 (file)
                                        // As a convenience feature, automatically restore warnings if they're
                                        // still suppressed by the end of the test.
                                        restoreWarnings();
+
+                                       // Check for (and clean up, if possible) incomplete animations/requests/etc.
+                                       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 );
+                                       }
                                }
                        };
                };