function JavascriptErrorsTest::testJavascriptErrors
Tests that JavaScript console errors will result in a test failure.
File
- 
              core/
tests/ Drupal/ FunctionalJavascriptTests/ JavascriptErrorsTest.php, line 29  
Class
- JavascriptErrorsTest
 - Tests that Drupal.throwError will cause a test failure.
 
Namespace
Drupal\FunctionalJavascriptTestsCode
public function testJavascriptErrors() : void {
  // Visit page that will throw a JavaScript console error.
  $this->drupalGet('js_errors_test');
  // Ensure that errors from previous page loads will be
  // detected.
  $this->drupalGet('user');
  $this->expectException(AssertionFailedError::class);
  $this->expectExceptionMessageMatches('/^Error: A manually thrown error/');
  // 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.