protected function WebDriverTestBase::failOnJavaScriptErrors in Drupal 10
Triggers a test failure if a JavaScript error was encountered.
@postCondition
Throws
\PHPUnit\Framework\AssertionFailedError
1 call to WebDriverTestBase::failOnJavaScriptErrors()
- JavascriptErrorsTest::testJavascriptErrors in core/
tests/ Drupal/ FunctionalJavascriptTests/ JavascriptErrorsTest.php - Tests that JavaScript console errors will result in a test failure.
File
- core/
tests/ Drupal/ FunctionalJavascriptTests/ WebDriverTestBase.php, line 129
Class
- WebDriverTestBase
- Runs a browser test using a driver that supports JavaScript.
Namespace
Drupal\FunctionalJavascriptTestsCode
protected function failOnJavaScriptErrors() : void {
if ($this->failOnJavascriptConsoleErrors) {
$errors = $this
->getSession()
->evaluateScript("JSON.parse(sessionStorage.getItem('js_testing_log_test.errors') || JSON.stringify([]))");
if (!empty($errors)) {
$this
->fail(implode("\n", $errors));
}
}
}