Unit testing with QUnit

This lessons covers

  • Why testing is important
  • What unit testing means
  • Installing QUnit
  • Testing your JavaScript code with QUnit
  • How to create a complete test suite with QUnit

The previous lesson was the last discussing concepts strictly related to the jQuery core. Deferred and Promise might have been tough arguments to learn but, hopefully, with our help the process has gone smoothly.

It’s now time for you to enhance your skills even further. In this lesson you’ll learn other tools and techniques that every pro must know. You’ll apply them to code written using jQuery, but you can reuse this knowledge with any code written in JavaScript. Testing is an essential concept to master if you’re working in a team or on anything that isn’t for your personal use only.

Important topics that you’ll explore in this lesson are tests and how to make assertions. An assertion is a way to verify that your code works correctly and your assumptions are respected. Stated another way, an assertion verifies that a function returns the value you expect given a set of inputs, or that the value of a variable or property of an object is what you expect after running some operations on it.

Finally, after a brief introduction about what unit testing is and why you should consider it, we’ll discuss QUnit. It’s one of the libraries available in the JavaScript community to unit test code written in JavaScript. The reason why we’ll talk about QUnit and not another library is that QUnit is the framework employed by all the jQuery projects (jQuery, jQuery UI, and jQuery Mobile) to unit test the code.

Without further ado, let’s discover more about testing, in particular unit testing, and QUnit.


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *