function WebDriverTestBase::failOnJavaScriptErrors
Same name in other branches
- 11.x core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php \Drupal\FunctionalJavascriptTests\WebDriverTestBase::failOnJavaScriptErrors()
Triggers a test failure if a JavaScript error was encountered.
@postCondition
Throws
\PHPUnit\Framework\AssertionFailedError
3 calls to WebDriverTestBase::failOnJavaScriptErrors()
- ContentTranslationConfigUITest::testContentTranslationConfigUI in core/
modules/ content_translation/ tests/ src/ FunctionalJavascript/ ContentTranslationConfigUITest.php - Tests that the content translation configuration javascript does't fail.
- JavascriptErrorsTest::testJavascriptErrors in core/
tests/ Drupal/ FunctionalJavascriptTests/ JavascriptErrorsTest.php - Tests that JavaScript console errors will result in a test failure.
- JavascriptErrorsTest::testJavascriptErrorsAsync in core/
tests/ Drupal/ FunctionalJavascriptTests/ JavascriptErrorsTest.php - Tests JavaScript console errors during asynchronous calls.
File
-
core/
tests/ Drupal/ FunctionalJavascriptTests/ WebDriverTestBase.php, line 134
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.