From: Timo Tijhof Date: Thu, 20 Nov 2014 17:54:05 +0000 (+0000) Subject: qunit/testrunner: Log relevant node in unfinished animations and reset X-Git-Tag: 1.31.0-rc.0~13175 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/rappels.php?a=commitdiff_plain;h=0615b0f2b91c0985313023d6183b56a7317147df;p=lhc%2Fweb%2Fwiklou.git qunit/testrunner: Log relevant node in unfinished animations and reset Having unfinished animations affect other test can be a problem, but when it does happen, having just a number isn't helpful in trying to pinpoint the cause. Logging a description of the element should make this relatively straight forward. Also reset the animations after the test so that the next test has a clean start (instead of the current situation where every subsequent test, until the animation finishes, also reports it as a failure). Example: Unfinished animation #0 in fx queue on
Change-Id: I41058c4cba3383e3ad1456990ccf8dae4ca64951 --- diff --git a/tests/qunit/data/testrunner.js b/tests/qunit/data/testrunner.js index 96a88f0975..b800bc251c 100644 --- a/tests/qunit/data/testrunner.js +++ b/tests/qunit/data/testrunner.js @@ -228,6 +228,7 @@ }, teardown: function () { + var timers; log( 'MwEnvironment> TEARDOWN for "' + QUnit.config.current.module + ': ' + QUnit.config.current.testName + '"' ); @@ -244,9 +245,18 @@ // 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 ); + timers = $.timers.length; + // Tests shoulld use fake timers or wait for animations to complete + $.each( $.timers, function ( i, timer ) { + var node = timer.elem; + mw.log.warn( 'Unfinished animation #' + i + ' in ' + timer.queue + ' queue on ' + + mw.html.element( node.nodeName.toLowerCase(), $(node).getAttrs() ) + ); + } ); + // Force animations to stop to give the next test a clean start + $.fx.stop(); + + throw new Error( 'Unfinished animations: ' + timers ); } if ( $.active !== undefined && $.active !== 0 ) { // Test may need to use fake XHR, wait for requests or