Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Jasmine, BDD for JavaScript

Chris Bushell
May 18, 2011
110

Jasmine, BDD for JavaScript

Prepared for the Melbourne Patterns Group

Chris Bushell

May 18, 2011
Tweet

Transcript

  1. Meet  Jasmine….     and  JsUnit   and  JsTestDriver  

    and  Screw.Unit   and  JSMockito   etc.  
  2. Why  Jasmine?   RSpec  like  syntax   Super  fast  

    Easy  to  integrate   Runs  anywhere  JavaScript  runs   Supports  tesWng  of  asynchronous  code  
  3. Jasmine  jQuery   •   Custom  matchers   •   toHaveHtml(string)  

    •   toBeHidden()   •   toBeSelected()   •   spyOnEvent($(‘#some  element’),  ‘click’)   •   An  API  for  loading  HTML  fixtures   •   loadFixtures(‘myFixturesFile.html’);  
  4. Working  with  the  DOM   •   DRY   •   Use

     your  applicaWon  to  generate  the   fixture  data  from  actual  views   •   Load  the  fixture  using  XHR   •   Example:  h1ps://github.com/pivotaljb/js-­‐ fixture-­‐example  
  5. Watch  out  for….   •   Syntax  errors  cause  specs  to

     fail   silently   •   Different  browsers,  different  traces