failOnJavaScriptErrors example

// 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();
  }

  /** * Tests JavaScript console errors during asynchronous calls. */
  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');

    
Home | Imprint | This part of the site doesn't use cookies.