Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Unit Testing

A few quick searches discovered that I'm obviously not the first person to have the thought "Can I unit test my CSS?".

I'm wondering if anyone here has taken on CSS Unit Testing successfully? If you've tried and failed, or just have your own theories, please tell me why it (apparently) hasn't been done yet?

like image 203
nickf Avatar asked Dec 05 '08 00:12

nickf


People also ask

Can you unit test CSS?

How do I test CSS then? As CSS should not impact the logic of a website, there is no unit to test.

Which method of CSS is best for testing?

Which Method of CSS is Best for Testing. Automatic CSS testing is the most reliable way of detecting breaking changes after a CMS update, or after updating plug-ins and themes.

Is unit testing worth the money?

Unit testing ensures that all code meets quality standards before it's deployed. This ensures a reliable engineering environment where quality is paramount. Over the course of the product development life cycle, unit testing saves time and money, and helps developers write better code, more efficiently.


1 Answers

You could use Selenium, which is a web testing framework. This way you could assert what styles are to be applied to elements in the DOM etc.

Selenium

Otherwise, not sure what your aim is. Unit testing is, as the name suggests, testing 'Units', and to me, this only makes sense with code, not css.

like image 179
RekrowYnapmoc Avatar answered Sep 29 '22 23:09

RekrowYnapmoc