O'Reilly logo

Learning jQuery - Fourth Edition by Karl Swedberg, Jonathan Chaffer

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

Organizing tests

QUnit provides two levels of test grouping named after their respective function calls: module() and test(). The module is like a general category under which the tests will be run; the test is actually a set of tests; the function takes a callback in which all of that test's specific unit tests are run. We'll group our tests by the chapter topic, placing the code in our test/test.js file:

module('Selecting');
test('Child Selector', function() {
  ok(true, 'Placeholder is entered');
});
test('Attribute Selectors', function() {
  ok(true, 'Placeholder is entered');
});
module('Ajax');

Listing B.1

It's not necessary to set up the file with this test structure, but it's good to have some overall structure in mind. In addition to the ...

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