SlideShare a Scribd company logo
1 of 57
Automated
Frontend Testing
                                                 NeilCrosby




     (Image from “The Korean Robot” - http://www.flickr.com/photos/zebrapares/1344995547/)
Who am I?

@NeilCrosby
European Frontend Architect for Search
at Yahoo!
I help look after frontend code quality.
What’s this talk about?


 • Automatically and regularly testing frontend
   code against known standards.
 • Why? What?     How? Where?
Why?
What? How?
 Where?
Why test?

• We all want to write code that works.
• Testing improves reliability.
• Repeatedly testing minimises regressions.
• Automatic testing can pick up “dumb-ass”
  mistakes.
That sounds lovely


• Normally that doesn’t happen though.
• Normally what happens is...
1. We build things.
They adhere to our
    standards.
2. We go to the pub.
3. Later, we add more
         code.
4. Our code stops
 adhering to our
    standards.
5. Things become less
   easy to maintain.
6. Bugs creep in.
7. We go to the pub in
       despair.
8. Repeat.
So...

• Test automatically and often.
• By adhering to a known standard, and
  constantly testing against it, it becomes
  easier to spot problems with the code that
  we're writing.
And that saves money
              Fewer bugs
                  ==
          Less time fixing bugs
                  ==
   More time developing new features.
Why?
What? How?
 Where?
What’s normally tested
   Backend         Frontend                In-Browser
(API, functions) (HTML, CSS, JS)           (Functional)
                   Validators, JsLint,
     *Unit                                   Selenium
                      YSlow etc.
                                           Sometimes
Automatic via CI        Manual
                                         automatic via CI
                    Adhoc, when
  Well defined                            Fairly well defined
                    remembered
Why not use Selenium?

 • Selenium tests code after it’s been
   interpreted by the browser.
 • Good for functional testing, not so good for
   testing discrete units of code.
Discrete Units?


• I’m looking at testing the quality of our
  HTML, CSS and JavaScript.
• It should all adhere to a known standard.
So we’re testing what?


• The code that leaves the server.
• Before it is interpreted by the browser.
What should we test?

• Currently I’m testing against:
 • W3C HTML Validator        validator.w3.org


 • W3C CSS Validator     jigsaw.w3.org/css-validator


 • JsLint jslint.com
Validation is a dirty word


  • People don’t like the word.
  • They always ask “what if?”.
Custom DTD


• Custom DTDs can help you create your
  own internal standard.
Custom DTDs are Easy

<!ENTITY % HTML.strict SYSTEM quot;strict.dtdquot;>
%HTML.strict;
<!ATTLIST OL
  %attrs; -- %coreattrs, %i18n, %events --
  start NUMBER #IMPLIED -- starting sequence number --
  >
Why?
What? How?
 Where?
How do I do this testing?


  • I’ve been writing a test suite!
  • http://github.com/NeilCrosby/frontend-
    test-suite (CC Attribution-Share Alike)
Currently in Phase 1


• Tests can easily be run against known units
  of HTML, CSS and JavaScript.
• I’m using phpunit as the framework.
HTML Testing

• By default tests against HTML 4.01 Strict.
• Test against custom DTDs.
• Module and full page testing.
• Test files, URLs or strings.
CSS Testing

• By default tests against CSS 2.1.
• Known exceptions to the standards can be
  allowed to pass validation.
• Test files, URLs or strings.
JavaScript Testing


• Test against any configuration JsLint allows.
• Test files, URLs or strings.
Add to your CI


• Run these tests in your hourly builds.
• Run them as a pre-commit hook.
Be a good citizen

• You’ll be running these tests frequently.
• Set up your own local versions of the
  HTML Validator, CSS Validator and JsLint.
• Instructions available on the web.
Running these tests

• If you need to test a simple site, it’s easy -
  pass a config object to
  TheCodeTrainEasyFrontendTestSuite.
• Otherwise, write custom TestCase
  extensions (still not hard).
Including the Suite

require_once(

     'TheCodeTrainEasyFrontendTestSuite.php'

);
Creating the Tests
class SomeTestSuite extends
TheCodeTrainEasyFrontendTestSuite {
    public static function suite() {
        return parent::suite(array(
          ‘html’ => array( ... ),
          ‘css’ => array( ... ),
          ‘js’ => array( ... ),
        ));
    }
}
Creating the Tests
class SomeTestSuite extends
TheCodeTrainEasyFrontendTestSuite {
    public static function suite() {
        return parent::suite(array(
          ‘html’ => array( ... ),
          ‘css’ => array( ... ),
          ‘js’ => array( ... ),
        ));
    }
}
Creating the Tests
class SomeTestSuite extends
TheCodeTrainEasyFrontendTestSuite {
    public static function suite() {
        return parent::suite(array(
         ‘html’ => array( ... ),
         ‘css’ => array( ... ),
         ‘js’ => array( ... ),
        ));
    }
}
Creating the Tests
class SomeTestSuite extends
TheCodeTrainEasyFrontendTestSuite {
    public static function suite() {
        return parent::suite(array(
         ‘html’ => array( ... ),
         ‘css’ => array( ... ),
         ‘js’ => array( ... ),
        ));
    }
}
The ‘html/css/js’ arrays
  ‘html’ => array(
      ‘validator’ => ‘http://yourvalidator’,
      ‘tests’ => array(
        ‘http://someurl.to/test’,
        ‘file://some/file/to/test’,
        ‘<p>Some string to test</p>’,
      ),
      ‘options’ => array( ... )
  )
The ‘html/css/js’ arrays
  ‘html’ => array(
      ‘validator’ => ‘http://yourvalidator’,
      ‘tests’ => array(
        ‘http://someurl.to/test’,
        ‘file://some/file/to/test’,
        ‘<p>Some string to test</p>’,
      ),
      ‘options’ => array( ... )
  )
The ‘html/css/js’ arrays
  ‘html’ => array(
      ‘validator’ => ‘http://yourvalidator’,
      ‘tests’ => array(
        ‘http://someurl.to/test’,
        ‘file://some/file/to/test’,
        ‘<p>Some string to test</p>’,
      ),
      ‘options’ => array( ... )
  )
The ‘html/css/js’ arrays
  ‘html’ => array(
      ‘validator’ => ‘http://yourvalidator’,
      ‘tests’ => array(
        ‘http://someurl.to/test’,
        ‘file://some/file/to/test’,
        ‘<p>Some string to test</p>’,
      ),
      ‘options’ => array( ... )
  )
The Options Array
‘options’ => array(
    ‘doctype_override’ =>
     ‘<!DOCTYPE HTML SYSTEM
     quot;http://site/doctype.dtdquot;>’,
    ‘document_section’ =>
     TheCodeTrainHtmlValidator::HTML_CHUNK,
    ‘document_section_position’ =>
     TheCodeTrainHtmlValidator::POSITION_HEAD
)
The Options Array
‘options’ => array(
    ‘doctype_override’ =>
     ‘<!DOCTYPE HTML SYSTEM
     quot;http://site/doctype.dtdquot;>’,
    ‘document_section’ =>
     TheCodeTrainHtmlValidator::HTML_CHUNK,
    ‘document_section_position’ =>
     TheCodeTrainHtmlValidator::POSITION_HEAD
)
The Options Array
‘options’ => array(
    ‘doctype_override’ =>
     ‘<!DOCTYPE HTML SYSTEM
     quot;http://site/doctype.dtdquot;>’,
    ‘document_section’ =>
     TheCodeTrainHtmlValidator::HTML_CHUNK,
    ‘document_section_position’ =>
     TheCodeTrainHtmlValidator::POSITION_HEAD
)
The Options Array
‘options’ => array(
    ‘doctype_override’ =>
     ‘<!DOCTYPE HTML SYSTEM
     quot;http://site/doctype.dtdquot;>’,
    ‘document_section’ =>
     TheCodeTrainHtmlValidator::HTML_CHUNK,
    ‘document_section_position’ =>
     TheCodeTrainHtmlValidator::POSITION_HEAD
)
Options?
• Custom doctypes, full page or module,
  position on page.
• Options can also be given for individual
  tests.
      array(
           ‘file://some/file/to/test’,
           array( your_options )
      )
Running these tests
> phpunit SomeTestSuite


PHPUnit 3.3.1 by Sebastian Bergmann.


.........


Time: 7 seconds


OK (9 tests, 9 assertions)
Some failures
....F.....


Failed asserting that
Array
(
    [0] => Array
     (
         [line] => 7
         [errortype] =>
         [error] => syntax of attribute value does not conform to declared value
         [original_line] => <label for=quot;quot;>Some label</label>
     )
)
 is false.
Some failures
.....F....


Failed asserting that
Array
(
    [0] => Array
     (
         [line] => 1
         [errortype] => parse-error
      [error] => Value Error : display (http://www.w3.org/TR/CSS21/
visuren.html#propdef-display) inlin is not a display value :
         [original_line] =>   p
     )
)
 is false.
Why?
What? How?
 Where?
Where’s this used?


• Yahoo! - SearchMonkey
• TheCodeTrain.co.uk’s WordPress theme.
It’s found problems

• Security holes.
• Form usability issues.
• Other suspect HTML.
The Future!
Phase 2 - The Future
• Test for things a simple DTD check can’t
  pick up on.
• CodeSniffer.
• Whitelisting sections of code - e.g. adverts.
• Basic accessibility testing - working with the
  experts at Yahoo!.
Available Online
• This talk: http://icanhaz.com/aft
• The Code (please fork and contribute):
  http://github.com/NeilCrosby/frontend-
  test-suite
• Twitter: automated frontend testing,
  @NeilCrosby
• My blog hub: http://neilcrosby.com

More Related Content

What's hot

Cómo Desarrollar Auditorías que Maximicen el éxito SEO #SEODay
Cómo Desarrollar Auditorías que Maximicen el éxito SEO #SEODayCómo Desarrollar Auditorías que Maximicen el éxito SEO #SEODay
Cómo Desarrollar Auditorías que Maximicen el éxito SEO #SEODayAleyda Solís
 
Search Engine Optimization Proposal PowerPoint Presentation Slides
Search Engine Optimization Proposal PowerPoint Presentation SlidesSearch Engine Optimization Proposal PowerPoint Presentation Slides
Search Engine Optimization Proposal PowerPoint Presentation SlidesSlideTeam
 
International SEO for E-Commerce Websites #SEJLive #SEJeSummit
International SEO for E-Commerce Websites #SEJLive #SEJeSummitInternational SEO for E-Commerce Websites #SEJLive #SEJeSummit
International SEO for E-Commerce Websites #SEJLive #SEJeSummitAleyda Solís
 
How to Make SEO Audits That Matter & Get Implemented for SEO Success - The Ex...
How to Make SEO Audits That Matter & Get Implemented for SEO Success - The Ex...How to Make SEO Audits That Matter & Get Implemented for SEO Success - The Ex...
How to Make SEO Audits That Matter & Get Implemented for SEO Success - The Ex...Aleyda Solís
 
Core Web Vitals Optimization for any website, especially WordPress
Core Web Vitals Optimization for any website, especially WordPressCore Web Vitals Optimization for any website, especially WordPress
Core Web Vitals Optimization for any website, especially WordPressClementYo
 
Create-React-App으로 SSR을 구현하며 배운 점 (feat. TypeScript)
Create-React-App으로 SSR을 구현하며 배운 점 (feat. TypeScript)Create-React-App으로 SSR을 구현하며 배운 점 (feat. TypeScript)
Create-React-App으로 SSR을 구현하며 배운 점 (feat. TypeScript)LanarkSeung
 
Cross browser testing using BrowserStack
Cross browser testing using BrowserStack Cross browser testing using BrowserStack
Cross browser testing using BrowserStack RapidValue
 
Small Tasks Make Big Changes - Shmulik Dorinbaum.pptx
Small Tasks Make Big Changes - Shmulik Dorinbaum.pptxSmall Tasks Make Big Changes - Shmulik Dorinbaum.pptx
Small Tasks Make Big Changes - Shmulik Dorinbaum.pptxShmulik Dorinbaum
 
BrightonSEO April 2023 Similar AI: Automation recipes for SEO success
BrightonSEO April 2023 Similar AI: Automation recipes for SEO successBrightonSEO April 2023 Similar AI: Automation recipes for SEO success
BrightonSEO April 2023 Similar AI: Automation recipes for SEO successDylan Fuler
 
BrightonSEO October 2022 - Martijn Scheybeler - SEO Testing: Find Out What Wo...
BrightonSEO October 2022 - Martijn Scheybeler - SEO Testing: Find Out What Wo...BrightonSEO October 2022 - Martijn Scheybeler - SEO Testing: Find Out What Wo...
BrightonSEO October 2022 - Martijn Scheybeler - SEO Testing: Find Out What Wo...Martijn Scheijbeler
 
Da Vuex a Pinia: come fare la migrazione
Da Vuex a Pinia: come fare la migrazioneDa Vuex a Pinia: come fare la migrazione
Da Vuex a Pinia: come fare la migrazioneCommit University
 
Refine your ci:cd pipeline with automated test
Refine your ci:cd pipeline with automated testRefine your ci:cd pipeline with automated test
Refine your ci:cd pipeline with automated testMalang QA Community
 
Google PageSpeed: 5 Steps to 100% (Mobile) Success
Google PageSpeed: 5 Steps to 100% (Mobile) SuccessGoogle PageSpeed: 5 Steps to 100% (Mobile) Success
Google PageSpeed: 5 Steps to 100% (Mobile) SuccessJoe Williams
 
TECHNICAL SEO QA - SHINING A LIGHT ON INVISIBLE WORK (BrightonSEO April 2022)
TECHNICAL SEO QA - SHINING A LIGHT ON INVISIBLE WORK (BrightonSEO April 2022)TECHNICAL SEO QA - SHINING A LIGHT ON INVISIBLE WORK (BrightonSEO April 2022)
TECHNICAL SEO QA - SHINING A LIGHT ON INVISIBLE WORK (BrightonSEO April 2022)Gianna Brachetti-Truskawa 🐙
 
Hacking the browser with puppeteer sharp .NET conf AR 2018
Hacking the browser with puppeteer sharp .NET conf AR 2018Hacking the browser with puppeteer sharp .NET conf AR 2018
Hacking the browser with puppeteer sharp .NET conf AR 2018Darío Kondratiuk
 
Crawling, indexation & the impact on performance | Brighton SEO
Crawling, indexation & the impact on performance | Brighton SEOCrawling, indexation & the impact on performance | Brighton SEO
Crawling, indexation & the impact on performance | Brighton SEOMartin Sean Fennon
 
BrightonSEO 2023 - Introduction to Search Engines Beyond Google - N Witczyk.pdf
BrightonSEO 2023 - Introduction to Search Engines Beyond Google - N Witczyk.pdfBrightonSEO 2023 - Introduction to Search Engines Beyond Google - N Witczyk.pdf
BrightonSEO 2023 - Introduction to Search Engines Beyond Google - N Witczyk.pdfNatalia Witczyk
 
How to rethink the traditional SEO workspace to promote team wellbeing and pr...
How to rethink the traditional SEO workspace to promote team wellbeing and pr...How to rethink the traditional SEO workspace to promote team wellbeing and pr...
How to rethink the traditional SEO workspace to promote team wellbeing and pr...Varn
 

What's hot (20)

Basic seo
Basic seoBasic seo
Basic seo
 
Cómo Desarrollar Auditorías que Maximicen el éxito SEO #SEODay
Cómo Desarrollar Auditorías que Maximicen el éxito SEO #SEODayCómo Desarrollar Auditorías que Maximicen el éxito SEO #SEODay
Cómo Desarrollar Auditorías que Maximicen el éxito SEO #SEODay
 
Search Engine Optimization Proposal PowerPoint Presentation Slides
Search Engine Optimization Proposal PowerPoint Presentation SlidesSearch Engine Optimization Proposal PowerPoint Presentation Slides
Search Engine Optimization Proposal PowerPoint Presentation Slides
 
Webpack slides
Webpack slidesWebpack slides
Webpack slides
 
International SEO for E-Commerce Websites #SEJLive #SEJeSummit
International SEO for E-Commerce Websites #SEJLive #SEJeSummitInternational SEO for E-Commerce Websites #SEJLive #SEJeSummit
International SEO for E-Commerce Websites #SEJLive #SEJeSummit
 
How to Make SEO Audits That Matter & Get Implemented for SEO Success - The Ex...
How to Make SEO Audits That Matter & Get Implemented for SEO Success - The Ex...How to Make SEO Audits That Matter & Get Implemented for SEO Success - The Ex...
How to Make SEO Audits That Matter & Get Implemented for SEO Success - The Ex...
 
Core Web Vitals Optimization for any website, especially WordPress
Core Web Vitals Optimization for any website, especially WordPressCore Web Vitals Optimization for any website, especially WordPress
Core Web Vitals Optimization for any website, especially WordPress
 
Create-React-App으로 SSR을 구현하며 배운 점 (feat. TypeScript)
Create-React-App으로 SSR을 구현하며 배운 점 (feat. TypeScript)Create-React-App으로 SSR을 구현하며 배운 점 (feat. TypeScript)
Create-React-App으로 SSR을 구현하며 배운 점 (feat. TypeScript)
 
Cross browser testing using BrowserStack
Cross browser testing using BrowserStack Cross browser testing using BrowserStack
Cross browser testing using BrowserStack
 
Small Tasks Make Big Changes - Shmulik Dorinbaum.pptx
Small Tasks Make Big Changes - Shmulik Dorinbaum.pptxSmall Tasks Make Big Changes - Shmulik Dorinbaum.pptx
Small Tasks Make Big Changes - Shmulik Dorinbaum.pptx
 
BrightonSEO April 2023 Similar AI: Automation recipes for SEO success
BrightonSEO April 2023 Similar AI: Automation recipes for SEO successBrightonSEO April 2023 Similar AI: Automation recipes for SEO success
BrightonSEO April 2023 Similar AI: Automation recipes for SEO success
 
BrightonSEO October 2022 - Martijn Scheybeler - SEO Testing: Find Out What Wo...
BrightonSEO October 2022 - Martijn Scheybeler - SEO Testing: Find Out What Wo...BrightonSEO October 2022 - Martijn Scheybeler - SEO Testing: Find Out What Wo...
BrightonSEO October 2022 - Martijn Scheybeler - SEO Testing: Find Out What Wo...
 
Da Vuex a Pinia: come fare la migrazione
Da Vuex a Pinia: come fare la migrazioneDa Vuex a Pinia: come fare la migrazione
Da Vuex a Pinia: come fare la migrazione
 
Refine your ci:cd pipeline with automated test
Refine your ci:cd pipeline with automated testRefine your ci:cd pipeline with automated test
Refine your ci:cd pipeline with automated test
 
Google PageSpeed: 5 Steps to 100% (Mobile) Success
Google PageSpeed: 5 Steps to 100% (Mobile) SuccessGoogle PageSpeed: 5 Steps to 100% (Mobile) Success
Google PageSpeed: 5 Steps to 100% (Mobile) Success
 
TECHNICAL SEO QA - SHINING A LIGHT ON INVISIBLE WORK (BrightonSEO April 2022)
TECHNICAL SEO QA - SHINING A LIGHT ON INVISIBLE WORK (BrightonSEO April 2022)TECHNICAL SEO QA - SHINING A LIGHT ON INVISIBLE WORK (BrightonSEO April 2022)
TECHNICAL SEO QA - SHINING A LIGHT ON INVISIBLE WORK (BrightonSEO April 2022)
 
Hacking the browser with puppeteer sharp .NET conf AR 2018
Hacking the browser with puppeteer sharp .NET conf AR 2018Hacking the browser with puppeteer sharp .NET conf AR 2018
Hacking the browser with puppeteer sharp .NET conf AR 2018
 
Crawling, indexation & the impact on performance | Brighton SEO
Crawling, indexation & the impact on performance | Brighton SEOCrawling, indexation & the impact on performance | Brighton SEO
Crawling, indexation & the impact on performance | Brighton SEO
 
BrightonSEO 2023 - Introduction to Search Engines Beyond Google - N Witczyk.pdf
BrightonSEO 2023 - Introduction to Search Engines Beyond Google - N Witczyk.pdfBrightonSEO 2023 - Introduction to Search Engines Beyond Google - N Witczyk.pdf
BrightonSEO 2023 - Introduction to Search Engines Beyond Google - N Witczyk.pdf
 
How to rethink the traditional SEO workspace to promote team wellbeing and pr...
How to rethink the traditional SEO workspace to promote team wellbeing and pr...How to rethink the traditional SEO workspace to promote team wellbeing and pr...
How to rethink the traditional SEO workspace to promote team wellbeing and pr...
 

Viewers also liked

Join the darkside: Selenium testing with Nightwatch.js
Join the darkside: Selenium testing with Nightwatch.jsJoin the darkside: Selenium testing with Nightwatch.js
Join the darkside: Selenium testing with Nightwatch.jsSeth McLaughlin
 
Browser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.jsBrowser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.jsLuís Bastião Silva
 
Front-End Testing: Demystified
Front-End Testing: DemystifiedFront-End Testing: Demystified
Front-End Testing: DemystifiedSeth McLaughlin
 
Fullstack End-to-end test automation with Node.js, one year later
Fullstack End-to-end test automation with Node.js, one year laterFullstack End-to-end test automation with Node.js, one year later
Fullstack End-to-end test automation with Node.js, one year laterMek Srunyu Stittri
 
Node.js and Selenium Webdriver, a journey from the Java side
Node.js and Selenium Webdriver, a journey from the Java sideNode.js and Selenium Webdriver, a journey from the Java side
Node.js and Selenium Webdriver, a journey from the Java sideMek Srunyu Stittri
 
Front-end Automated Testing
Front-end Automated TestingFront-end Automated Testing
Front-end Automated TestingRuben Teijeiro
 
PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js
PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.jsPayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js
PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.jsApplitools
 
Building testable chrome extensions
Building testable chrome extensionsBuilding testable chrome extensions
Building testable chrome extensionsSeth McLaughlin
 
How To Combine Back-End 
 & Front-End Testing with BlazeMeter & Sauce Labs
How To Combine Back-End 
 & Front-End Testing with BlazeMeter & Sauce LabsHow To Combine Back-End 
 & Front-End Testing with BlazeMeter & Sauce Labs
How To Combine Back-End 
 & Front-End Testing with BlazeMeter & Sauce LabsSauce Labs
 
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016Gavin Pickin
 
Varshneya samdarshi lmu_symposium_2016
Varshneya samdarshi lmu_symposium_2016Varshneya samdarshi lmu_symposium_2016
Varshneya samdarshi lmu_symposium_2016GRNsight
 
Introduction To Web Application Testing
Introduction To Web Application TestingIntroduction To Web Application Testing
Introduction To Web Application TestingYnon Perek
 
Javascript Unit Testing Tools
Javascript Unit Testing ToolsJavascript Unit Testing Tools
Javascript Unit Testing ToolsPixelCrayons
 
Web based automation testing on Node.js environment
Web based automation testing on Node.js environmentWeb based automation testing on Node.js environment
Web based automation testing on Node.js environmentYu-Lin Huang
 
Automated Testing in WordPress, Really?!
Automated Testing in WordPress, Really?!Automated Testing in WordPress, Really?!
Automated Testing in WordPress, Really?!Ptah Dunbar
 
Test Automation With Cucumber JVM, Selenium, and Mocha
Test Automation With Cucumber JVM, Selenium, and MochaTest Automation With Cucumber JVM, Selenium, and Mocha
Test Automation With Cucumber JVM, Selenium, and MochaSalesforce Developers
 

Viewers also liked (20)

Join the darkside: Selenium testing with Nightwatch.js
Join the darkside: Selenium testing with Nightwatch.jsJoin the darkside: Selenium testing with Nightwatch.js
Join the darkside: Selenium testing with Nightwatch.js
 
Browser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.jsBrowser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.js
 
Front-End Testing: Demystified
Front-End Testing: DemystifiedFront-End Testing: Demystified
Front-End Testing: Demystified
 
Fullstack End-to-end test automation with Node.js, one year later
Fullstack End-to-end test automation with Node.js, one year laterFullstack End-to-end test automation with Node.js, one year later
Fullstack End-to-end test automation with Node.js, one year later
 
Node.js and Selenium Webdriver, a journey from the Java side
Node.js and Selenium Webdriver, a journey from the Java sideNode.js and Selenium Webdriver, a journey from the Java side
Node.js and Selenium Webdriver, a journey from the Java side
 
Night Watch with QA
Night Watch with QANight Watch with QA
Night Watch with QA
 
Front-end Automated Testing
Front-end Automated TestingFront-end Automated Testing
Front-end Automated Testing
 
Laravel Unit Testing
Laravel Unit TestingLaravel Unit Testing
Laravel Unit Testing
 
PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js
PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.jsPayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js
PayPal's NemoJS and Applitools Eyes - Visual Testing with Node.js
 
Building testable chrome extensions
Building testable chrome extensionsBuilding testable chrome extensions
Building testable chrome extensions
 
PAVE
PAVEPAVE
PAVE
 
How to write Testable Javascript
How to write Testable JavascriptHow to write Testable Javascript
How to write Testable Javascript
 
How To Combine Back-End 
 & Front-End Testing with BlazeMeter & Sauce Labs
How To Combine Back-End 
 & Front-End Testing with BlazeMeter & Sauce LabsHow To Combine Back-End 
 & Front-End Testing with BlazeMeter & Sauce Labs
How To Combine Back-End 
 & Front-End Testing with BlazeMeter & Sauce Labs
 
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
 
Varshneya samdarshi lmu_symposium_2016
Varshneya samdarshi lmu_symposium_2016Varshneya samdarshi lmu_symposium_2016
Varshneya samdarshi lmu_symposium_2016
 
Introduction To Web Application Testing
Introduction To Web Application TestingIntroduction To Web Application Testing
Introduction To Web Application Testing
 
Javascript Unit Testing Tools
Javascript Unit Testing ToolsJavascript Unit Testing Tools
Javascript Unit Testing Tools
 
Web based automation testing on Node.js environment
Web based automation testing on Node.js environmentWeb based automation testing on Node.js environment
Web based automation testing on Node.js environment
 
Automated Testing in WordPress, Really?!
Automated Testing in WordPress, Really?!Automated Testing in WordPress, Really?!
Automated Testing in WordPress, Really?!
 
Test Automation With Cucumber JVM, Selenium, and Mocha
Test Automation With Cucumber JVM, Selenium, and MochaTest Automation With Cucumber JVM, Selenium, and Mocha
Test Automation With Cucumber JVM, Selenium, and Mocha
 

Similar to Automated Frontend Testing

Testing ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETTesting ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETBen Hall
 
Efficient JavaScript Development
Efficient JavaScript DevelopmentEfficient JavaScript Development
Efficient JavaScript Developmentwolframkriesing
 
Code Quality Practice and Tools
Code Quality Practice and ToolsCode Quality Practice and Tools
Code Quality Practice and ToolsBob Paulin
 
Token Testing Slides
Token  Testing SlidesToken  Testing Slides
Token Testing Slidesericholscher
 
Testing Ext JS and Sencha Touch
Testing Ext JS and Sencha TouchTesting Ext JS and Sencha Touch
Testing Ext JS and Sencha TouchMats Bryntse
 
Browser-Based testing using Selenium
Browser-Based testing using SeleniumBrowser-Based testing using Selenium
Browser-Based testing using Seleniumret0
 
Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...
Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...
Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...BradNeuberg
 
Java script unit testing
Java script unit testingJava script unit testing
Java script unit testingMats Bryntse
 
High Performance Django 1
High Performance Django 1High Performance Django 1
High Performance Django 1DjangoCon2008
 
High Performance Django
High Performance DjangoHigh Performance Django
High Performance DjangoDjangoCon2008
 
WebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
WebTest - Efficient Functional Web Testing with HtmlUnit and BeyondWebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
WebTest - Efficient Functional Web Testing with HtmlUnit and Beyondmguillem
 
Nanoformats
NanoformatsNanoformats
Nanoformatsrozario
 
An Introduction To jQuery
An Introduction To jQueryAn Introduction To jQuery
An Introduction To jQueryAndy Gibson
 
Progressive Enhancement with JavaScript and Ajax
Progressive Enhancement with JavaScript and AjaxProgressive Enhancement with JavaScript and Ajax
Progressive Enhancement with JavaScript and AjaxChristian Heilmann
 
Efficient JavaScript Development
Efficient JavaScript DevelopmentEfficient JavaScript Development
Efficient JavaScript Developmentwolframkriesing
 
Developer Tests - Things to Know
Developer Tests - Things to KnowDeveloper Tests - Things to Know
Developer Tests - Things to KnowVaidas Pilkauskas
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptdavejohnson
 

Similar to Automated Frontend Testing (20)

Testing ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETTesting ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NET
 
Efficient JavaScript Development
Efficient JavaScript DevelopmentEfficient JavaScript Development
Efficient JavaScript Development
 
Code Quality Practice and Tools
Code Quality Practice and ToolsCode Quality Practice and Tools
Code Quality Practice and Tools
 
Token Testing Slides
Token  Testing SlidesToken  Testing Slides
Token Testing Slides
 
Testing Ext JS and Sencha Touch
Testing Ext JS and Sencha TouchTesting Ext JS and Sencha Touch
Testing Ext JS and Sencha Touch
 
Browser-Based testing using Selenium
Browser-Based testing using SeleniumBrowser-Based testing using Selenium
Browser-Based testing using Selenium
 
Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...
Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...
Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...
 
Java script unit testing
Java script unit testingJava script unit testing
Java script unit testing
 
High Performance Django 1
High Performance Django 1High Performance Django 1
High Performance Django 1
 
High Performance Django
High Performance DjangoHigh Performance Django
High Performance Django
 
Wt unit 2 ppts client sied technology
Wt unit 2 ppts client sied technologyWt unit 2 ppts client sied technology
Wt unit 2 ppts client sied technology
 
Wt unit 2 ppts client side technology
Wt unit 2 ppts client side technologyWt unit 2 ppts client side technology
Wt unit 2 ppts client side technology
 
WebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
WebTest - Efficient Functional Web Testing with HtmlUnit and BeyondWebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
WebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
 
Nanoformats
NanoformatsNanoformats
Nanoformats
 
Test
TestTest
Test
 
An Introduction To jQuery
An Introduction To jQueryAn Introduction To jQuery
An Introduction To jQuery
 
Progressive Enhancement with JavaScript and Ajax
Progressive Enhancement with JavaScript and AjaxProgressive Enhancement with JavaScript and Ajax
Progressive Enhancement with JavaScript and Ajax
 
Efficient JavaScript Development
Efficient JavaScript DevelopmentEfficient JavaScript Development
Efficient JavaScript Development
 
Developer Tests - Things to Know
Developer Tests - Things to KnowDeveloper Tests - Things to Know
Developer Tests - Things to Know
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScript
 

More from Neil Crosby

team++; making your team work better together
team++; making your team work better togetherteam++; making your team work better together
team++; making your team work better togetherNeil Crosby
 
Geolocation and Beer
Geolocation and BeerGeolocation and Beer
Geolocation and BeerNeil Crosby
 
Yahoo! Pipes: Munging, Mixing and Mashing
Yahoo! Pipes: Munging, Mixing and MashingYahoo! Pipes: Munging, Mixing and Mashing
Yahoo! Pipes: Munging, Mixing and MashingNeil Crosby
 
Search Monkey - Open Hack London '09
Search Monkey - Open Hack London '09Search Monkey - Open Hack London '09
Search Monkey - Open Hack London '09Neil Crosby
 
I'll Show You Mine If You Show Me Yours...
I'll Show You Mine If You Show Me Yours...I'll Show You Mine If You Show Me Yours...
I'll Show You Mine If You Show Me Yours...Neil Crosby
 
TV Tubes - Talkin' 'bout my automation...
TV Tubes - Talkin' 'bout my automation...TV Tubes - Talkin' 'bout my automation...
TV Tubes - Talkin' 'bout my automation...Neil Crosby
 
Starting to Monkey Around With Yahoo! Search Monkey
Starting to Monkey Around With Yahoo! Search MonkeyStarting to Monkey Around With Yahoo! Search Monkey
Starting to Monkey Around With Yahoo! Search MonkeyNeil Crosby
 
Multi-level vCards
Multi-level vCardsMulti-level vCards
Multi-level vCardsNeil Crosby
 

More from Neil Crosby (11)

team++; making your team work better together
team++; making your team work better togetherteam++; making your team work better together
team++; making your team work better together
 
team++
team++team++
team++
 
Geolocation and Beer
Geolocation and BeerGeolocation and Beer
Geolocation and Beer
 
Lagging Pipes
Lagging PipesLagging Pipes
Lagging Pipes
 
Yahoo! Pipes: Munging, Mixing and Mashing
Yahoo! Pipes: Munging, Mixing and MashingYahoo! Pipes: Munging, Mixing and Mashing
Yahoo! Pipes: Munging, Mixing and Mashing
 
Search Monkey - Open Hack London '09
Search Monkey - Open Hack London '09Search Monkey - Open Hack London '09
Search Monkey - Open Hack London '09
 
I'll Show You Mine If You Show Me Yours...
I'll Show You Mine If You Show Me Yours...I'll Show You Mine If You Show Me Yours...
I'll Show You Mine If You Show Me Yours...
 
TV Tubes - Talkin' 'bout my automation...
TV Tubes - Talkin' 'bout my automation...TV Tubes - Talkin' 'bout my automation...
TV Tubes - Talkin' 'bout my automation...
 
Starting to Monkey Around With Yahoo! Search Monkey
Starting to Monkey Around With Yahoo! Search MonkeyStarting to Monkey Around With Yahoo! Search Monkey
Starting to Monkey Around With Yahoo! Search Monkey
 
Multi-level vCards
Multi-level vCardsMulti-level vCards
Multi-level vCards
 
Twitter Bots
Twitter BotsTwitter Bots
Twitter Bots
 

Recently uploaded

guest bathroom white and bluesssssssssss
guest bathroom white and bluesssssssssssguest bathroom white and bluesssssssssss
guest bathroom white and bluesssssssssssNadaMohammed714321
 
Making and Unmaking of Chandigarh - A City of Two Plans2-4-24.ppt
Making and Unmaking of Chandigarh - A City of Two Plans2-4-24.pptMaking and Unmaking of Chandigarh - A City of Two Plans2-4-24.ppt
Making and Unmaking of Chandigarh - A City of Two Plans2-4-24.pptJIT KUMAR GUPTA
 
Unit1_Syllbwbnwnwneneneneneneentation_Sem2.pptx
Unit1_Syllbwbnwnwneneneneneneentation_Sem2.pptxUnit1_Syllbwbnwnwneneneneneneentation_Sem2.pptx
Unit1_Syllbwbnwnwneneneneneneentation_Sem2.pptxNitish292041
 
10 must-have Chrome extensions for designers
10 must-have Chrome extensions for designers10 must-have Chrome extensions for designers
10 must-have Chrome extensions for designersPixeldarts
 
AI and Design Vol. 2: Navigating the New Frontier - Morgenbooster
AI and Design Vol. 2: Navigating the New Frontier - MorgenboosterAI and Design Vol. 2: Navigating the New Frontier - Morgenbooster
AI and Design Vol. 2: Navigating the New Frontier - Morgenbooster1508 A/S
 
FW25-26 Knit Cut & Sew Trend Book Peclers Paris
FW25-26 Knit Cut & Sew Trend Book Peclers ParisFW25-26 Knit Cut & Sew Trend Book Peclers Paris
FW25-26 Knit Cut & Sew Trend Book Peclers ParisPeclers Paris
 
CAPITAL GATE CASE STUDY -regional case study.pdf
CAPITAL GATE CASE STUDY -regional case study.pdfCAPITAL GATE CASE STUDY -regional case study.pdf
CAPITAL GATE CASE STUDY -regional case study.pdfAlasAlthaher
 
Map of St. Louis Parks
Map of St. Louis Parks                              Map of St. Louis Parks
Map of St. Louis Parks CharlottePulte
 
10 Best WordPress Plugins to make the website effective in 2024
10 Best WordPress Plugins to make the website effective in 202410 Best WordPress Plugins to make the website effective in 2024
10 Best WordPress Plugins to make the website effective in 2024digital learning point
 
NBA power point presentation final copy y
NBA power point presentation final copy yNBA power point presentation final copy y
NBA power point presentation final copy ysrajece
 
The spirit of digital place - game worlds and architectural phenomenology
The spirit of digital place - game worlds and architectural phenomenologyThe spirit of digital place - game worlds and architectural phenomenology
The spirit of digital place - game worlds and architectural phenomenologyChristopher Totten
 
Karim apartment ideas 01 ppppppppppppppp
Karim apartment ideas 01 pppppppppppppppKarim apartment ideas 01 ppppppppppppppp
Karim apartment ideas 01 pppppppppppppppNadaMohammed714321
 
Piece by Piece Magazine
Piece by Piece Magazine                      Piece by Piece Magazine
Piece by Piece Magazine CharlottePulte
 
DAKSHIN BIHAR GRAMIN BANK: REDEFINING THE DIGITAL BANKING EXPERIENCE WITH A U...
DAKSHIN BIHAR GRAMIN BANK: REDEFINING THE DIGITAL BANKING EXPERIENCE WITH A U...DAKSHIN BIHAR GRAMIN BANK: REDEFINING THE DIGITAL BANKING EXPERIENCE WITH A U...
DAKSHIN BIHAR GRAMIN BANK: REDEFINING THE DIGITAL BANKING EXPERIENCE WITH A U...Rishabh Aryan
 
怎么办理英国Newcastle毕业证纽卡斯尔大学学位证书一手渠道
怎么办理英国Newcastle毕业证纽卡斯尔大学学位证书一手渠道怎么办理英国Newcastle毕业证纽卡斯尔大学学位证书一手渠道
怎么办理英国Newcastle毕业证纽卡斯尔大学学位证书一手渠道yrolcks
 
Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025Rndexperts
 
Interior Design for Office a cura di RMG Project Studio
Interior Design for Office a cura di RMG Project StudioInterior Design for Office a cura di RMG Project Studio
Interior Design for Office a cura di RMG Project StudioRMG Project Studio
 
world health day 2024.pptxgbbvggvbhjjjbbbb
world health day 2024.pptxgbbvggvbhjjjbbbbworld health day 2024.pptxgbbvggvbhjjjbbbb
world health day 2024.pptxgbbvggvbhjjjbbbbpreetirao780
 
guest bathroom white and blue ssssssssss
guest bathroom white and blue ssssssssssguest bathroom white and blue ssssssssss
guest bathroom white and blue ssssssssssNadaMohammed714321
 
Niintendo Wii Presentation Template.pptx
Niintendo Wii Presentation Template.pptxNiintendo Wii Presentation Template.pptx
Niintendo Wii Presentation Template.pptxKevinYaelJimnezSanti
 

Recently uploaded (20)

guest bathroom white and bluesssssssssss
guest bathroom white and bluesssssssssssguest bathroom white and bluesssssssssss
guest bathroom white and bluesssssssssss
 
Making and Unmaking of Chandigarh - A City of Two Plans2-4-24.ppt
Making and Unmaking of Chandigarh - A City of Two Plans2-4-24.pptMaking and Unmaking of Chandigarh - A City of Two Plans2-4-24.ppt
Making and Unmaking of Chandigarh - A City of Two Plans2-4-24.ppt
 
Unit1_Syllbwbnwnwneneneneneneentation_Sem2.pptx
Unit1_Syllbwbnwnwneneneneneneentation_Sem2.pptxUnit1_Syllbwbnwnwneneneneneneentation_Sem2.pptx
Unit1_Syllbwbnwnwneneneneneneentation_Sem2.pptx
 
10 must-have Chrome extensions for designers
10 must-have Chrome extensions for designers10 must-have Chrome extensions for designers
10 must-have Chrome extensions for designers
 
AI and Design Vol. 2: Navigating the New Frontier - Morgenbooster
AI and Design Vol. 2: Navigating the New Frontier - MorgenboosterAI and Design Vol. 2: Navigating the New Frontier - Morgenbooster
AI and Design Vol. 2: Navigating the New Frontier - Morgenbooster
 
FW25-26 Knit Cut & Sew Trend Book Peclers Paris
FW25-26 Knit Cut & Sew Trend Book Peclers ParisFW25-26 Knit Cut & Sew Trend Book Peclers Paris
FW25-26 Knit Cut & Sew Trend Book Peclers Paris
 
CAPITAL GATE CASE STUDY -regional case study.pdf
CAPITAL GATE CASE STUDY -regional case study.pdfCAPITAL GATE CASE STUDY -regional case study.pdf
CAPITAL GATE CASE STUDY -regional case study.pdf
 
Map of St. Louis Parks
Map of St. Louis Parks                              Map of St. Louis Parks
Map of St. Louis Parks
 
10 Best WordPress Plugins to make the website effective in 2024
10 Best WordPress Plugins to make the website effective in 202410 Best WordPress Plugins to make the website effective in 2024
10 Best WordPress Plugins to make the website effective in 2024
 
NBA power point presentation final copy y
NBA power point presentation final copy yNBA power point presentation final copy y
NBA power point presentation final copy y
 
The spirit of digital place - game worlds and architectural phenomenology
The spirit of digital place - game worlds and architectural phenomenologyThe spirit of digital place - game worlds and architectural phenomenology
The spirit of digital place - game worlds and architectural phenomenology
 
Karim apartment ideas 01 ppppppppppppppp
Karim apartment ideas 01 pppppppppppppppKarim apartment ideas 01 ppppppppppppppp
Karim apartment ideas 01 ppppppppppppppp
 
Piece by Piece Magazine
Piece by Piece Magazine                      Piece by Piece Magazine
Piece by Piece Magazine
 
DAKSHIN BIHAR GRAMIN BANK: REDEFINING THE DIGITAL BANKING EXPERIENCE WITH A U...
DAKSHIN BIHAR GRAMIN BANK: REDEFINING THE DIGITAL BANKING EXPERIENCE WITH A U...DAKSHIN BIHAR GRAMIN BANK: REDEFINING THE DIGITAL BANKING EXPERIENCE WITH A U...
DAKSHIN BIHAR GRAMIN BANK: REDEFINING THE DIGITAL BANKING EXPERIENCE WITH A U...
 
怎么办理英国Newcastle毕业证纽卡斯尔大学学位证书一手渠道
怎么办理英国Newcastle毕业证纽卡斯尔大学学位证书一手渠道怎么办理英国Newcastle毕业证纽卡斯尔大学学位证书一手渠道
怎么办理英国Newcastle毕业证纽卡斯尔大学学位证书一手渠道
 
Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025
 
Interior Design for Office a cura di RMG Project Studio
Interior Design for Office a cura di RMG Project StudioInterior Design for Office a cura di RMG Project Studio
Interior Design for Office a cura di RMG Project Studio
 
world health day 2024.pptxgbbvggvbhjjjbbbb
world health day 2024.pptxgbbvggvbhjjjbbbbworld health day 2024.pptxgbbvggvbhjjjbbbb
world health day 2024.pptxgbbvggvbhjjjbbbb
 
guest bathroom white and blue ssssssssss
guest bathroom white and blue ssssssssssguest bathroom white and blue ssssssssss
guest bathroom white and blue ssssssssss
 
Niintendo Wii Presentation Template.pptx
Niintendo Wii Presentation Template.pptxNiintendo Wii Presentation Template.pptx
Niintendo Wii Presentation Template.pptx
 

Automated Frontend Testing

  • 1. Automated Frontend Testing NeilCrosby (Image from “The Korean Robot” - http://www.flickr.com/photos/zebrapares/1344995547/)
  • 2. Who am I? @NeilCrosby European Frontend Architect for Search at Yahoo! I help look after frontend code quality.
  • 3. What’s this talk about? • Automatically and regularly testing frontend code against known standards. • Why? What? How? Where?
  • 5. Why test? • We all want to write code that works. • Testing improves reliability. • Repeatedly testing minimises regressions. • Automatic testing can pick up “dumb-ass” mistakes.
  • 6. That sounds lovely • Normally that doesn’t happen though. • Normally what happens is...
  • 7. 1. We build things. They adhere to our standards.
  • 8. 2. We go to the pub.
  • 9. 3. Later, we add more code.
  • 10. 4. Our code stops adhering to our standards.
  • 11. 5. Things become less easy to maintain.
  • 13. 7. We go to the pub in despair.
  • 15. So... • Test automatically and often. • By adhering to a known standard, and constantly testing against it, it becomes easier to spot problems with the code that we're writing.
  • 16. And that saves money Fewer bugs == Less time fixing bugs == More time developing new features.
  • 18. What’s normally tested Backend Frontend In-Browser (API, functions) (HTML, CSS, JS) (Functional) Validators, JsLint, *Unit Selenium YSlow etc. Sometimes Automatic via CI Manual automatic via CI Adhoc, when Well defined Fairly well defined remembered
  • 19. Why not use Selenium? • Selenium tests code after it’s been interpreted by the browser. • Good for functional testing, not so good for testing discrete units of code.
  • 20. Discrete Units? • I’m looking at testing the quality of our HTML, CSS and JavaScript. • It should all adhere to a known standard.
  • 21. So we’re testing what? • The code that leaves the server. • Before it is interpreted by the browser.
  • 22. What should we test? • Currently I’m testing against: • W3C HTML Validator validator.w3.org • W3C CSS Validator jigsaw.w3.org/css-validator • JsLint jslint.com
  • 23. Validation is a dirty word • People don’t like the word. • They always ask “what if?”.
  • 24. Custom DTD • Custom DTDs can help you create your own internal standard.
  • 25. Custom DTDs are Easy <!ENTITY % HTML.strict SYSTEM quot;strict.dtdquot;> %HTML.strict; <!ATTLIST OL %attrs; -- %coreattrs, %i18n, %events -- start NUMBER #IMPLIED -- starting sequence number -- >
  • 27. How do I do this testing? • I’ve been writing a test suite! • http://github.com/NeilCrosby/frontend- test-suite (CC Attribution-Share Alike)
  • 28. Currently in Phase 1 • Tests can easily be run against known units of HTML, CSS and JavaScript. • I’m using phpunit as the framework.
  • 29. HTML Testing • By default tests against HTML 4.01 Strict. • Test against custom DTDs. • Module and full page testing. • Test files, URLs or strings.
  • 30. CSS Testing • By default tests against CSS 2.1. • Known exceptions to the standards can be allowed to pass validation. • Test files, URLs or strings.
  • 31. JavaScript Testing • Test against any configuration JsLint allows. • Test files, URLs or strings.
  • 32. Add to your CI • Run these tests in your hourly builds. • Run them as a pre-commit hook.
  • 33. Be a good citizen • You’ll be running these tests frequently. • Set up your own local versions of the HTML Validator, CSS Validator and JsLint. • Instructions available on the web.
  • 34. Running these tests • If you need to test a simple site, it’s easy - pass a config object to TheCodeTrainEasyFrontendTestSuite. • Otherwise, write custom TestCase extensions (still not hard).
  • 35. Including the Suite require_once( 'TheCodeTrainEasyFrontendTestSuite.php' );
  • 36. Creating the Tests class SomeTestSuite extends TheCodeTrainEasyFrontendTestSuite { public static function suite() { return parent::suite(array( ‘html’ => array( ... ), ‘css’ => array( ... ), ‘js’ => array( ... ), )); } }
  • 37. Creating the Tests class SomeTestSuite extends TheCodeTrainEasyFrontendTestSuite { public static function suite() { return parent::suite(array( ‘html’ => array( ... ), ‘css’ => array( ... ), ‘js’ => array( ... ), )); } }
  • 38. Creating the Tests class SomeTestSuite extends TheCodeTrainEasyFrontendTestSuite { public static function suite() { return parent::suite(array( ‘html’ => array( ... ), ‘css’ => array( ... ), ‘js’ => array( ... ), )); } }
  • 39. Creating the Tests class SomeTestSuite extends TheCodeTrainEasyFrontendTestSuite { public static function suite() { return parent::suite(array( ‘html’ => array( ... ), ‘css’ => array( ... ), ‘js’ => array( ... ), )); } }
  • 40. The ‘html/css/js’ arrays ‘html’ => array( ‘validator’ => ‘http://yourvalidator’, ‘tests’ => array( ‘http://someurl.to/test’, ‘file://some/file/to/test’, ‘<p>Some string to test</p>’, ), ‘options’ => array( ... ) )
  • 41. The ‘html/css/js’ arrays ‘html’ => array( ‘validator’ => ‘http://yourvalidator’, ‘tests’ => array( ‘http://someurl.to/test’, ‘file://some/file/to/test’, ‘<p>Some string to test</p>’, ), ‘options’ => array( ... ) )
  • 42. The ‘html/css/js’ arrays ‘html’ => array( ‘validator’ => ‘http://yourvalidator’, ‘tests’ => array( ‘http://someurl.to/test’, ‘file://some/file/to/test’, ‘<p>Some string to test</p>’, ), ‘options’ => array( ... ) )
  • 43. The ‘html/css/js’ arrays ‘html’ => array( ‘validator’ => ‘http://yourvalidator’, ‘tests’ => array( ‘http://someurl.to/test’, ‘file://some/file/to/test’, ‘<p>Some string to test</p>’, ), ‘options’ => array( ... ) )
  • 44. The Options Array ‘options’ => array( ‘doctype_override’ => ‘<!DOCTYPE HTML SYSTEM quot;http://site/doctype.dtdquot;>’, ‘document_section’ => TheCodeTrainHtmlValidator::HTML_CHUNK, ‘document_section_position’ => TheCodeTrainHtmlValidator::POSITION_HEAD )
  • 45. The Options Array ‘options’ => array( ‘doctype_override’ => ‘<!DOCTYPE HTML SYSTEM quot;http://site/doctype.dtdquot;>’, ‘document_section’ => TheCodeTrainHtmlValidator::HTML_CHUNK, ‘document_section_position’ => TheCodeTrainHtmlValidator::POSITION_HEAD )
  • 46. The Options Array ‘options’ => array( ‘doctype_override’ => ‘<!DOCTYPE HTML SYSTEM quot;http://site/doctype.dtdquot;>’, ‘document_section’ => TheCodeTrainHtmlValidator::HTML_CHUNK, ‘document_section_position’ => TheCodeTrainHtmlValidator::POSITION_HEAD )
  • 47. The Options Array ‘options’ => array( ‘doctype_override’ => ‘<!DOCTYPE HTML SYSTEM quot;http://site/doctype.dtdquot;>’, ‘document_section’ => TheCodeTrainHtmlValidator::HTML_CHUNK, ‘document_section_position’ => TheCodeTrainHtmlValidator::POSITION_HEAD )
  • 48. Options? • Custom doctypes, full page or module, position on page. • Options can also be given for individual tests. array( ‘file://some/file/to/test’, array( your_options ) )
  • 49. Running these tests > phpunit SomeTestSuite PHPUnit 3.3.1 by Sebastian Bergmann. ......... Time: 7 seconds OK (9 tests, 9 assertions)
  • 50. Some failures ....F..... Failed asserting that Array ( [0] => Array ( [line] => 7 [errortype] => [error] => syntax of attribute value does not conform to declared value [original_line] => <label for=quot;quot;>Some label</label> ) ) is false.
  • 51. Some failures .....F.... Failed asserting that Array ( [0] => Array ( [line] => 1 [errortype] => parse-error [error] => Value Error : display (http://www.w3.org/TR/CSS21/ visuren.html#propdef-display) inlin is not a display value : [original_line] => p ) ) is false.
  • 53. Where’s this used? • Yahoo! - SearchMonkey • TheCodeTrain.co.uk’s WordPress theme.
  • 54. It’s found problems • Security holes. • Form usability issues. • Other suspect HTML.
  • 56. Phase 2 - The Future • Test for things a simple DTD check can’t pick up on. • CodeSniffer. • Whitelisting sections of code - e.g. adverts. • Basic accessibility testing - working with the experts at Yahoo!.
  • 57. Available Online • This talk: http://icanhaz.com/aft • The Code (please fork and contribute): http://github.com/NeilCrosby/frontend- test-suite • Twitter: automated frontend testing, @NeilCrosby • My blog hub: http://neilcrosby.com

Editor's Notes

  1. I&#x2019;m also lazy.
  2. Unfiltered data labels pointing to non-existent input elements