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: ...
Get Jasmine Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.