Krinkle has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/348251 )

Change subject: qunit: Improve testrunner logging for pending ajax
......................................................................

qunit: Improve testrunner logging for pending ajax

* Move `restoreWarnings()` in tearDown() to the mirrored location
  of related code in setUp().

* Log all ajax requests logged during the test, not just the
  one currently still pending. This should avoid situations
  where we throw "Pending ajax requests" but no information
  is logged about which requests those might be.

Change-Id: I900ad98c4c8520bdd6ae00a24ac82272f3becfee
---
M tests/qunit/data/testrunner.js
1 file changed, 9 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/51/348251/1

diff --git a/tests/qunit/data/testrunner.js b/tests/qunit/data/testrunner.js
index b0118af..e7c190e 100644
--- a/tests/qunit/data/testrunner.js
+++ b/tests/qunit/data/testrunner.js
@@ -215,6 +215,10 @@
                                        // Stop tracking ajax requests
                                        $( document ).off( 'ajaxSend', 
trackAjax );
 
+                                       // As a convenience feature, 
automatically restore warnings if they're
+                                       // still suppressed by the end of the 
test.
+                                       restoreWarnings();
+
                                        // Farewell, mock environment!
                                        mw.config = liveConfig;
                                        mw.messages = liveMessages;
@@ -222,10 +226,6 @@
                                        mw.jqueryMsg.setParserDefaults( {
                                                messages: liveMessages
                                        } );
-
-                                       // As a convenience feature, 
automatically restore warnings if they're
-                                       // still suppressed by the end of the 
test.
-                                       restoreWarnings();
 
                                        // Tests should use fake timers or wait 
for animations to complete
                                        // Check for incomplete 
animations/requests/etc and throw if there are any.
@@ -253,8 +253,11 @@
                                                        mw.log.warn( 'Pending 
requests does not match jQuery.active count' );
                                                }
                                                // Force requests to stop to 
give the next test a clean start
-                                               $.each( pending, function ( i, 
ajax ) {
-                                                       mw.log.warn( 'Pending 
AJAX request #' + i, ajax.options );
+                                               $.each( ajaxRequests, function 
( i, ajax ) {
+                                                       mw.log.warn(
+                                                               'AJAX request 
#' + i + ' (state: ' + ajax.xhr.state() + ')',
+                                                               ajax.options
+                                                       );
                                                        ajax.xhr.abort();
                                                } );
                                                ajaxRequests = [];

-- 
To view, visit https://gerrit.wikimedia.org/r/348251
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I900ad98c4c8520bdd6ae00a24ac82272f3becfee
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <krinklem...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to