function AjaxWaitTest::testUnnecessaryWait

Same name in other branches
  1. 11.x core/tests/Drupal/FunctionalJavascriptTests/AjaxWaitTest.php \Drupal\FunctionalJavascriptTests\AjaxWaitTest::testUnnecessaryWait()

Tests that an unnecessary wait triggers a deprecation error.

File

core/tests/Drupal/FunctionalJavascriptTests/AjaxWaitTest.php, line 23

Class

AjaxWaitTest
Tests that unnecessary or untracked XHRs will cause a test failure.

Namespace

Drupal\FunctionalJavascriptTests

Code

public function testUnnecessaryWait() : void {
    $this->drupalGet('user');
    $this->expectDeprecation("Drupal\\FunctionalJavascriptTests\\JSWebAssert::assertExpectedAjaxRequest called unnecessarily in a test is deprecated in drupal:10.2.0 and will throw an exception in drupal:11.0.0. See https://www.drupal.org/node/3401201");
    $this->expectException(\RuntimeException::class);
    $this->expectExceptionMessage('Unable to complete AJAX request.');
    $this->assertSession()
        ->assertWaitOnAjaxRequest(500);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.