Automated Tests and CSS

44
Automated Testing & CSS Kevin Lamping, Rackspace Front-end Engineer @klamping

Transcript of Automated Tests and CSS

Page 1: Automated Tests and CSS

Automated Testing& CSSKevin Lamping, RackspaceFront-end Engineer@klamping

Page 2: Automated Tests and CSS

When I change the CSS

Page 3: Automated Tests and CSS

“Insanity: doing the same thing over and over again and expecting different results.”

Page 4: Automated Tests and CSS

“Insanity: doing the same thing over and over again and enjoying it.”

Page 5: Automated Tests and CSS
Page 6: Automated Tests and CSS
Page 7: Automated Tests and CSS
Page 8: Automated Tests and CSS
Page 9: Automated Tests and CSS
Page 10: Automated Tests and CSS
Page 11: Automated Tests and CSS

“Despite CSS being so hard to maintain, it's often the part of the FE stack people are least interested in protecting from tech debt.” @necolas

Page 12: Automated Tests and CSS

The ToolsWraith, Hardy, StyleDocco

Page 13: Automated Tests and CSS

Wraith

Page 14: Automated Tests and CSS
Page 15: Automated Tests and CSS

+

Page 16: Automated Tests and CSS
Page 17: Automated Tests and CSS
Page 18: Automated Tests and CSS

Installation$ curl -fsSL https://raw.github.com/bbc-news/wraith/go/install | bash$ cd wraith$ bundle install

Page 19: Automated Tests and CSS

Demo

Page 20: Automated Tests and CSS

Wraith - Recap

•Easy, simple set up•Nice site to view diffs•Entire screen comparison is bad

for dynamic sites•No IE Testing•Need two sites with same content

Page 21: Automated Tests and CSS
Page 22: Automated Tests and CSS
Page 23: Automated Tests and CSS

Installation$ npm install -g hardy

Page 24: Automated Tests and CSS

Demo

Page 25: Automated Tests and CSS

Selector Mapsselectors.jsmodule.exports = { "standard paragraph": "section > p"};

test.featureThen "standard paragraph" should have "color" of "rgb(68, 68, 68)"

Page 26: Automated Tests and CSS

selectors.jsmodule.exports = { "standard paragraph": "section > p"};

test.featureThen "standard paragraph" should have "color" of "rgb(68, 68, 68)"

Selector Maps

Page 27: Automated Tests and CSS

CSS Testing StepsThen "section > p" should have "color" of "rgb(68, 68, 68)"

Page 28: Automated Tests and CSS

CSS Testing StepsThen <css selector> should have <property> of <value>

Page 29: Automated Tests and CSS

CSS Testing StepsThen <css selector> should have <property> of <greater|less> than <value>

Page 30: Automated Tests and CSS

CSS Testing StepsThen <css selector> should have offset <top or left> of <value>

Page 31: Automated Tests and CSS

CSS Testing StepsThen <css selector> should look the same as before

Page 32: Automated Tests and CSS

Demo

Page 33: Automated Tests and CSS

Basic Steps

Given I visit "http://csste.st/"

Page 34: Automated Tests and CSS

Basic Steps

Given the window size is <width> by <height>

Page 35: Automated Tests and CSS

Basic Steps

Then I enter <string> into <css selector>

Page 36: Automated Tests and CSS

Basic Steps

Then I submit the form <css selector>

Page 37: Automated Tests and CSS

Demo

Page 38: Automated Tests and CSS

Custom Steps

Page 39: Automated Tests and CSS

Hardy - Recap

•Cross-browser coverage•Computed styles & specific shots•Site scripting built-in•No nice diff page•More work to set up•Have to repeat CSS•Pay attention to ' and "

Page 40: Automated Tests and CSS

StyleDocco

Page 41: Automated Tests and CSS

/* # Buttons

Provides extra visual weight and identifies the primary action in a set of buttons.

```<button class="btn primary">Primary</button><button class="btn primary :hover">Primary</button>``` */

Page 42: Automated Tests and CSS

Demo

Page 43: Automated Tests and CSS

StyleDocco - Recap

•No login/scripting needed•Allows for pseudo-class testing•Content is (mostly) static•Not the actual site

Page 44: Automated Tests and CSS

Get Involved!http://csste.st

Thanks!