{"id":3062,"date":"2014-01-29T00:31:00","date_gmt":"2014-01-29T00:31:00","guid":{"rendered":"https:\/\/www.htmlgoodies.com\/uncategorized\/testing-dom-events-using-jquery-and-jasmine-2-0\/"},"modified":"2021-04-23T20:38:01","modified_gmt":"2021-04-23T20:38:01","slug":"testing-dom-events-using-jquery-and-jasmine-2-0","status":"publish","type":"post","link":"https:\/\/www.htmlgoodies.com\/javascript\/testing-dom-events-using-jquery-and-jasmine-2-0\/","title":{"rendered":"Testing DOM Events Using jQuery and Jasmine 2.0"},"content":{"rendered":"

A lot of processes within a Web application are triggered by Document Object Model (DOM) events. These include button clicks, setting the focus on an element, document loading, unloading, and any other event resulting from a user action or the browser. That’s why any good Unit Testing Framework will provide methods to deal with DOM events. Jasmine is no exception. It makes it possible to test that a given event occurred and what the results of the event were. In today’s article, we’re going to create some tests for the button click event using Jasmine 2.0, jQuery, and an additional third-party library.<\/p>\n

<\/h2>\n

What You’ll Need<\/h2>\n

The add-on library that we’ll be using is built on Jasmine 2.0 and jQuery and is called jasmine-jquery. Here are the details on it and the other two libraries:<\/p>\n