function WebDriverTestBase::failOnJavaScriptErrors
Same name and namespace in other branches
- 11.x core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php \Drupal\FunctionalJavascriptTests\WebDriverTestBase::failOnJavaScriptErrors()
- 10 core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php \Drupal\FunctionalJavascriptTests\WebDriverTestBase::failOnJavaScriptErrors()
Triggers a test failure if a JavaScript error was encountered.
Attributes
#[PostCondition]
Throws
\PHPUnit\Framework\AssertionFailedError
2 calls to WebDriverTestBase::failOnJavaScriptErrors()
- ActiveLinkTest::testQueryStringQuotes in core/
modules/ system/ tests/ src/ FunctionalJavascript/ ActiveLinkTest.php - Ensures no JS error is thrown with query strings containing special chars.
- ContentTranslationConfigUITest::testContentTranslationConfigUI in core/
modules/ content_translation/ tests/ src/ FunctionalJavascript/ ContentTranslationConfigUITest.php - Tests that the content translation configuration javascript does't fail.
File
-
core/
tests/ Drupal/ FunctionalJavascriptTests/ WebDriverTestBase.php, line 121
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));
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.