Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 297337

Fail Functional Javascript tests that throw Javascript errors

$
0
0

Problem/Motivation

Our phpunit based functional javascript test will pass even if there are Javascript errors on the page.

While we test JS functionality sometimes a JS error will not break our tests because the core functionality still works but other JS that is the page of a particular site could be broken.

A user ran into this scenario on #3072231: Custom blocks break layout builder module - Quick Edit could not associate the rendered entity field markup

Proposed resolution

if a Javascript error is thrown to during a test fail the test.

Additionally

  1. All core tests should fail on Console errors by default. Each class should not need to set a property so that we cannot ignore console errors in core tests by forgetting this property
  2. Core tests should be able to set the property protected $failOnJavascriptConsoleErrors = FALSE; to suppress errors for 2 reasons
    1) This will allows use to commit this with known errors such as #3091878: MediaEmbedFilterConfigurationUiTest throws a Javascript Error or any others we find at the time we are able to commit this this issue. Before we commit this at any point we can't be sure how many tests will fail with this patch applied. We could be adding new tests that throw JS console errors with any commit.
    2)After this patch is committed we could have tests start to fail for a number of reasons such as, changes in the chrome driver/browser Drupalci uses or needed updates to our JS dependences. In the example of our JS dependencies these could be security updates that we need ASAP but also cause a small non-important JS console error. In such cases we should be able to commit the dependency updates and do a follow-up to fix the error.
  3. Any class that extends \Drupal\FunctionalJavascriptTests\WebDriverTestBaseexcept core test, i.e Contrib and custom test, should have to opt in this behavior by setting protected $failOnJavascriptConsoleErrors = TRUE;. This will ensure a bunch of contrib tests will not start to fail after we commit this patch. We could consider changing this to opt out in Drupal 10
  4. Contrib/custom tests should be able to opt in a bunch of classes at once by setting protected $failOnJavascriptConsoleErrors = TRUE; in a base test class like, MyModuleTestBase

Remaining tasks

All

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

TBD


Viewing all articles
Browse latest Browse all 297337

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>