Usage and Examples

QUnit uses a set of top-level functions to provide semantic meaning in unit tests:
  • module(string) - defines a module
  • test(string, function) - defines a test
  • ok(boolean, string) - validates to true or false
  • equal(value1, value2, message) - compares two values
  • expect(any) - defines a value to expect from a test
A basic example would be as follows:

test("a basic test example", function() {
  ok( true, "this test is fine" );
  var value = "hello";
  equal( value, "hello", "We expect value to be hello" );
});