Sample code for my VT Code Camp 2012 presentation on headless JavaScript unit testing with Jasmine BDD and PhantomJS.
JavaScript Shell
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Like a Genie from the Lamp:

Headless JavaScript Testing with Jasmine and PhantomJS

Example code to accompany my presentation on using Jasmine and PhantomJS for lightning-fast JavaScript unit tests, a talk that was given at the 2012 VT Code Camp.


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.

Running the Code

  • Download/install PhantomJS; make sure it's on your PATH.
  • Checkout this repository; cd into the repo and run these commands:
    • git submodule init
    • git submodule update
  • From within the repo:
    • phantomjs lib/jasmine-reporters/test/phantomjs-testrunner.js $(pwd)/test/all-tests-spec.htm