O'Reilly logo

Web Development Recipes, 2nd Edition by Chris Johnson, Mike Weber, Chris Warren, Brian P. Hogan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Recipe 37Testing JavaScript with Jasmine

Problem

JavaScript can be difficult to test accurately, because its flexibility and dynamic nature make it moving target. We can do browser testing with the Selenium IDE (Recipe 35, Browser Testing with Selenium), but that still requires manual JavaScript debugging with the console and doesn’t give us direct information about functions that are broken. What we need is a full testing framework for JavaScript.

Ingredients

Solution

Jasmine is a JavaScript testing framework created by Pivotal Labs to allow behavior-driven development (BDD) in JavaScript. Jasmine’s syntax is similar to that of Ruby’s RSpec testing framework.[117] (You can find out more ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required