Approaches to test CSS
Syntax checks
Styleguides & linting
Comparing screenshots
Comparing styles in DOM
Styleguides & linting
@import "other.css";
div {
padding: 0px 10px;
}
- Prevents anti-patterns
- Easy to apply
- Doesn't test end result
- Useless without good linting rules
- No changes can sneak by
- Content-fragile
Comparing styles in DOM
window.getComputedStyle();
Hardy / Cucumber
Scenario: Standard paragraph color
Given I visit "http://local.gemini.com/about.html"
Then ".container > p" should have
"color" of "rgb(64, 64, 64)"
- Resilient to changes
- Reduces unintended consequences
- Writing expectations in code
- Style rules != look
- Structure-fragile
There is no "silver bullet", yet.
CSS regression testing
Presented by Sergey Semashko