diff --git a/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php b/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php
index 8f1ead5..c190ee2 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php
@@ -34,6 +34,21 @@ protected function initMink() {
   }
 
   /**
+   * {@inheritdoc}
+   */
+  protected function tearDown() {
+    // Wait for all requests to finish. It is possible that an AJAX request is
+    // still on-going.
+    $result = $this->getSession()->wait(5000, '(typeof(jQuery)=="undefined" || (0 === jQuery.active && 0 === jQuery(\':animated\').length))');
+    if (!$result) {
+      // Throw an exception to ensure errors are not obfuscated by missing
+      // session table errors.
+      throw new \RuntimeException('Unfinished AJAX requests whilst tearing down a test');
+    }
+    parent::tearDown();
+  }
+
+  /**
    * Asserts that the element with the given CSS selector is visible.
    *
    * @param string $css_selector
