function JavascriptErrorsTest::testJavascriptErrorsAsync
Same name in other branches
- 10 core/tests/Drupal/FunctionalJavascriptTests/JavascriptErrorsTest.php \Drupal\FunctionalJavascriptTests\JavascriptErrorsTest::testJavascriptErrorsAsync()
Tests JavaScript console errors during asynchronous calls.
File
-
core/
tests/ Drupal/ FunctionalJavascriptTests/ JavascriptErrorsTest.php, line 47
Class
- JavascriptErrorsTest
- Tests that Drupal.throwError will cause a test failure.
Namespace
Drupal\FunctionalJavascriptTestsCode
public function testJavascriptErrorsAsync() : void {
// Visit page that will throw a JavaScript console error in async context.
$this->drupalGet('js_errors_async_test');
// Ensure that errors from previous page loads will be detected.
$this->drupalGet('user');
$this->expectException(AssertionFailedError::class);
$this->expectExceptionMessageMatches('/^Error: An error thrown in async context./');
// Manually call the method under test, as it cannot be caught by PHPUnit
// when triggered from assertPostConditions().
$this->failOnJavaScriptErrors();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.