O'Reilly logo

Jasmine Cookbook by Munish Sethi

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

Writing Jasmine specs for jQuery

In the first recipe, we looked at how to write Jasmine specs for AJAX calls using the jasmine-ajax plugin. In this recipe, you will learn how to write tests for jQuery and DOM manipulation in Jasmine specs.

Getting ready

To understand how to write Jasmine specs with jQuery, let's create the myfixture.html file and consider the following code:

<!DOCTYPE html>
<html>
<body>
<div id="my-fixture">something</div>
</body>
</html>

Here, we simply created HTML file with a div tag and defined id as my-fixture.

Next, let's create the jQuery_example.js file and consider the following code:

function sendRequestWithJQuery(myCallback,showErrorMessage,configurationData) { $.ajax({ url: configurationData.url, dataType: "json", success: ...

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