O'Reilly logo

Instant Testing with QUnit by Dmitry Sheiko

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

Testing assertions (Simple)

Assertion is the main method used in testing. In this recipe, we will examine all the assertion methods that QUnit has. Besides, we will take a look at a few assertion methods provided by popular QUnit plugins.

Getting ready

It would be much more useful if while learning assertions, we test the real code. The following two helper functions are quite suitable to show discrete cases of the use of assertions:

var utils = (function() { "use strict"; return { /** * Port of PHP trim function which differ from EcmaScript 5 String.prototype.trim * Strip whitespace (or other characters) from the beginning and end of a string * Without the second parameter, trim() will strip these characters: * " " (ASCII 32 (0x20)), an ordinary ...

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