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

Twig debug mode breaks tests

$
0
0

I don't think is is necessarily a bug as such, but automated tests that perform assertions directly against rendered HTML will fail when Twig debug mode is enabled. This is because the debug mode wraps the output of each Twig template with HTML comments containing debug information, so while the element is still intact and correct, performing a direct comparison against known good HTML will fail.

For example, this small test fragment fails when debug mode is on, even though the output is displayed correctly to the user

$img_tag = theme('image_style', $variables);
$this->assertEqual($img_tag, '<img class="image-style-test" src="' . $url . '" width="120" height="60" alt="" />');

In an ideal world, tests shouldn't be doing assertions against HTML strings IMO, but since that's not a fight I want to get into I suggest adding a note to the documentation in default.settings.php that warns of potential false failures when debug mode is enabled.


Viewing all articles
Browse latest Browse all 291671

Trending Articles



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