Testing Autmation Strategy for Twig template

by arpitr   Last Updated June 12, 2019 21:07 PM

I am using Drupal 8 CMS for a media platform, which essentially uses twig templating engine. We are using component based approach, building small re-usbale building blocks instead of building the complete page.

Now each component has its twig file and stylesheet for css rules.

My question is can these what testing strategy suits better for automating testing strategy for the twig templates?

  • Unit Testing
  • Funtional Testing

Looks like phpunit has a way to test twig templates in isolation https://stackoverflow.com/questions/17026405/twig-template-unit-testing

But to me it appears to be overkill to have unit testing for templating engine, since twig templates are not meant to have complex business logic but yes it could be simple if else conditional branching on template.

Functional Test seems to be better candidate for this sort of assertions, but yes functional tests are slow since they are opinionated about database connections unlike unit tests.

Let me emphasis on my question again for a media platform using Drupal 8 as CMS what testing strategy suits better to test frontend twig templates? Is it

  • Unit Tests
  • Functional Tests


Related Questions


Updated March 05, 2019 18:07 PM

Updated January 08, 2019 06:07 AM

Updated July 09, 2015 13:03 PM

Updated June 19, 2015 01:03 AM

Updated March 26, 2015 10:02 AM