50. Assert
ok(state, message)
Passes if the first argument is truthy.
var bbq_ready = true;
QUnit.ok(bbq_ready, 'Barbecue ready!.');
var bbq_ready = false;
QUnit.ok(bbq_ready, 'Barbecue ready!.');
51. Assert
equal(actual, expected, message)
Simple comparison operator (==) to compare the
actual and expected arguments.
var bbq = 'Bacon';
QUnit.equal(bbq, 'Bacon', 'Bacon barbecue!');
QUnit.equal(bbq, 'Chicken', 'Chicken barbecue!');
52. Assert
notEqual(actual, expected, message)
Simple inverted comparison operator (!=) to
compare the actual and expected arguments.
var bbq = 'Bacon';
QUnit.notEqual(bbq, 'Salad', 'No salad!');
var bbq = 'Salad';
QUnit.notEqual(bbq, 'Salad', 'No salad!');
53. Assert
deepEqual(actual, expected, message)
Just like equal() when comparing objects, such
that { key: value } is equal to { key: value }.
var bbq = {meat: 'Bacon'};
QUnit.deepEqual(bbq,
{meat: 'Bacon'}, 'Bacon barbecue!');
var bbq = {meat: 'Chicken'};
QUnit.deepEqual(bbq,
{meat: 'Bacon'}, 'Bacon barbecue!');
54. Assert
notDeepEqual(actual, expected, message)
Just like notEqual() when comparing objects, such
that { key: value } is not equal to { key: value }.
var bbq = {food: 'Bacon'};
QUnit.notDeepEqual(bbq,
{food: 'Salad'}, 'No salad!');
var bbq = {food: 'Salad'};
QUnit.notDeepEqual(bbq,
{food: 'Salad'}, 'No salad!');
55. Assert
strictEqual(actual, expected, message)
Most rigid comparison of type and value with the
strict equality operator (===).
var bacon = '1';
QUnit.strictEqual(bacon, '1', 'Bacon!');
QUnit.strictEqual(bacon, 1, 'Bacon!');
56. Assert
notStrictEqual(actual, expected, message)
Most rigid comparison of type and value with the
strict inverted equality operator (!==).
var bacon = '1';
QUnit.notStrictEqual(bacon, 1, 'No Bacon!');
QUnit.notStrictEqual(bacon, '1', 'No Bacon!');
58. Expect
expect(amount)
Specify how many assertions are expected to run
within a test. If the number of assertions run does
not match the expected count, the test will fail.
var bbq = 'Bacon';
// Good
QUnit.expect(1);
QUnit.equal(bbq, 'Bacon', 'Bacon barbecue!');
// Wrong
QUnit.expect(1);
QUnit.equal(bbq, 'Bacon', 'Bacon barbecue!');
QUnit.notEqual(bbq, 'Chicken', 'Chicken barbecue!');