Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
LIKE A GENIE FROM THE LAMP    Headless JavaScript Testing with Jasmine and PhantomJSRob Friesel                           ...
WHO IS THIS GUY?• Sr. User         Interface Developer at Dealer.com Websystems• out   there on the web:  • @founddrama  •...
WHAT ARE WE TALKING  ABOUT TODAY?
IN THE BEGINNING...
But then we discover...UNIT TESTING
BENEFITS OF UNIT TESTING
DEMO
SO WHATS THE PROBLEM?
AUTOMATION
var page = new WebPage();  page.onConsoleMessage = function(msg) {    console.log(msg);  };  console.log([phantomjs] Loadi...
ARE YOU THINKINGWHAT IM THINKING?
LETS DO SOMETHING      AWESOME!
QUESTIONS?
THANKS!
RESOURCES• Jasmine    : http://pivotal.github.com/jasmine/• PhantomJS     : http://phantomjs.org/• Larry   Myers jasmine-r...
Like a Genie from a Lamp: Headless JavaScript Unit Testing with Jasmine and PhantomJS
Like a Genie from a Lamp: Headless JavaScript Unit Testing with Jasmine and PhantomJS
Like a Genie from a Lamp: Headless JavaScript Unit Testing with Jasmine and PhantomJS
Like a Genie from a Lamp: Headless JavaScript Unit Testing with Jasmine and PhantomJS
Like a Genie from a Lamp: Headless JavaScript Unit Testing with Jasmine and PhantomJS
Like a Genie from a Lamp: Headless JavaScript Unit Testing with Jasmine and PhantomJS
Upcoming SlideShare
Loading in …5
×

Like a Genie from a Lamp: Headless JavaScript Unit Testing with Jasmine and PhantomJS

3,551 views

Published on

Jasmine is a mature BDD test framework for JavaScript, and though powerful and feature-rich in its own right, you are often still shackled to a browser window to conduct your tests. Tools like Selenium WebDriver make automated testing possible, but they are difficult to set up, cumbersome to use, and worst of all slow. Wouldn't it be nice if you could execute your tests as part of your build? And have those tests before completed in seconds? With PhantomJS ("the headless WebKit") that wish has come true. In this talk we will introduce the Jasmine BDD test framework, introduce PhantomJS, and demonstrate how to execute your Jasmine tests in PhantomJS for lightning fast results.

The code and discussion points from this talk appear on Github: https://github.com/founddrama/vt-code-camp-2012

UPDATE (July 2014): this talk became the seed for this book that I wrote: "The PhantomJS Cookbook" - http://goo.gl/NJnFq1

Published in: Technology, Education

Like a Genie from a Lamp: Headless JavaScript Unit Testing with Jasmine and PhantomJS

  1. 1. LIKE A GENIE FROM THE LAMP Headless JavaScript Testing with Jasmine and PhantomJSRob Friesel @founddrama
  2. 2. WHO IS THIS GUY?• Sr. User Interface Developer at Dealer.com Websystems• out there on the web: • @founddrama • blog.founddrama.net • github.com/founddrama
  3. 3. WHAT ARE WE TALKING ABOUT TODAY?
  4. 4. IN THE BEGINNING...
  5. 5. But then we discover...UNIT TESTING
  6. 6. BENEFITS OF UNIT TESTING
  7. 7. DEMO
  8. 8. SO WHATS THE PROBLEM?
  9. 9. AUTOMATION
  10. 10. var page = new WebPage(); page.onConsoleMessage = function(msg) {   console.log(msg); }; console.log([phantomjs] Loading page...); page.open(encodeURI(http://blog.founddrama.net/), function(status){   if (status !== success) {     console.log(could not retrieve!);   } else {     page.evaluate(function(){       console.log([phantomjs] Querying for post titles...);       var list = Array.prototype.slice.call( document.querySelectorAll(h2 > a[rel="bookmark"]), 0);       console.log([phantomjs] + list.length + post titles:);       list.forEach(function(el){         console.log( + el.innerHTML.replace(/<.*?>/g, ));       });     });   }   phantom.exit(); });
  11. 11. ARE YOU THINKINGWHAT IM THINKING?
  12. 12. LETS DO SOMETHING AWESOME!
  13. 13. QUESTIONS?
  14. 14. THANKS!
  15. 15. RESOURCES• Jasmine : http://pivotal.github.com/jasmine/• PhantomJS : http://phantomjs.org/• Larry Myers jasmine-reporters : https://github.com/larrymyers/jasmine-reporters• this talks sample code : https://github.com/founddrama/vt-code-camp-2012

×