Slide 1

Slide 1 text

P H A N T O M C S S W I T H I N W E B U I A R C H I T E C T U R E

Slide 2

Slide 2 text

PhantomCSS is a CasperJS module for automating visual regression testing with PhantomJS and Resemble.js. For testing Web apps, live style guides and responsive layouts

Slide 3

Slide 3 text

Test coverage of UI without implementation coupling. Tests that reflect what the user sees, not what the developer writes

Slide 4

Slide 4 text

• Manual testing is a time consuming process • The risk of regression is higher with responsive layouts and complex applications • CSS refactoring is necessary for long life projects • Visual regression identification can often be difficult and subjective W H Y ?

Slide 5

Slide 5 text

casper.start( url ).then(function(){ casper.click(‘button’); phantomCSS.screenshot( ‘.modal’, ‘Modal dialog’ ); });

Slide 6

Slide 6 text

- More logs casperjs test demo/testsuite.js --verbose —log-level=debug - Use SlimerJS instead of PhantomJS casperjs test demo/testsuite.js --engine=slimerjs - Use debugger; statements with Webkit remote console casperjs test demo/testsuite.js —remote-debugger-port=9000 CO M M A N D L I N E

Slide 7

Slide 7 text

CO M M A N D L I N E

Slide 8

Slide 8 text

• Write the test • Run the test • Check the baseline image • Git ignore the ‘diff’ images • Commit the baseline image B A S I C WO R K F LO W

Slide 9

Slide 9 text

S Y S T E M U N D E R T E S T J A VA S C R I P T H T M L C S S F I X T U R E I N T E R FA C E PhantomCSS provides implicit test coverage of behaviour, template and style regardless of technology choices.

Slide 10

Slide 10 text

– M A R T I N F O W L E R “A classic test only cares about the final state - not how that state was derived. ” J A VA S C R I P T H T M L C S S F I X T U R E I N T E R FA C E Visual regression tests can also be Unit tests. They’re fast, and can be run individually and in any order.

Slide 11

Slide 11 text

Isolating the system under test makes feedback faster and tests less fragile. Confidence in tests makes applications easier and cheaper to change, extend and refactor J A VA S C R I P T H T M L C S S F I X T U R E I N T E R FA C E

Slide 12

Slide 12 text

Visual regression testing as isolated Unit tests is core to Huddle’s front-end Web application architecture J A VA S C R I P T H T M L C S S F I X T U R E I N T E R FA C E

Slide 13

Slide 13 text

Developed at Huddle; tools that help people gather, review, create and share content. A complex Javascript Web application

Slide 14

Slide 14 text

1532 visual tests in total Visual Functional

Slide 15

Slide 15 text

• Simple UI components do not speak directly with backend services • Complex UI components handle request/response with backend services. They are composed of other complex and simple UI components. • Complex and simple components require different test strategies, but both benefit from PhantomCSS coverage S I M P L E & C O M P L E X U I C O M P O N E N T S

Slide 16

Slide 16 text

S I M P L E & C O M P L E X U I C O M P O N E N T S Encapsulated behaviours with declarative inputs

Slide 17

Slide 17 text

S I M P L E & C O M P L E X U I C O M P O N E N T S Variations are generated automatically for both documentation and tests

Slide 18

Slide 18 text

S I M P L E & C O M P L E X U I C O M P O N E N T S External dependencies are faked in code

Slide 19

Slide 19 text

S I M P L E & C O M P L E X U I C O M P O N E N T S Fake setups can be evaluated from tests as well as in a hot-reload development environment

Slide 20

Slide 20 text

S I M P L E & C O M P L E X U I C O M P O N E N T S Fake setups can be evaluated from tests to support visual regression testing with PhantomCSS

Slide 21

Slide 21 text

https://github.com/huddle/phantomcss @ J A M E S C RY E R P H A N T O M C S S W I T H I N W E B U I A R C H I T E C T U R E