Assertions
Methods
# deepEqual (actual, expected, messageopt) static
Tests for deep equality.
Arguments:
actual
:expected
:message
:
# doesNotThrow (block, erroropt, messageopt) static
Expects block not to throw an error, see assert.throws for details.
Arguments:
block
:error
:message
:
# equal (actual, expected, messageopt: String) static
Tests shallow, coercive equality with the equal comparison operator ( == ).
Arguments:
actual
:expected
:message
: String
# ifError (err) static
Tests if value is not a false value, throws if it is a true value. Useful when testing the first argument, error in callbacks.
Arguments:
err
:
# notDeepEqual (actual, expected, messageopt) static
Tests for any deep inequality.
Arguments:
actual
:expected
:message
:
# notEqual (actual, expected, messageopt) static
Tests shallow, coercive non-equality with the not equal comparison operator ( != ).
Arguments:
actual
:expected
:message
:
# throws (block, erroropt, messageopt) static
Expects block to throw an error. error can be constructor, RegExp or validation function.
Validate instanceof using constructor:
assert.throws(function() {
throw new Error("Wrong value");
}, Error);
Validate error message using RegExp:
assert.throws(function() {
throw new Error("Wrong value");
}, /error/);
Custom error validation:
assert.throws(
function() {
throw new Error("Wrong value");
},
function(err) {
if ( (err instanceof Error) && /value/.test(err) ) {
return true;
}
},
"unexpected error"
);
Arguments:
block
:error
:message
:
# fail (actual, expected, message, operator, stackStartFunction) inner
Throws an exception that displays the values for actual and expected separated by the provided operator.
Arguments:
actual
:expected
:message
:operator
:stackStartFunction
:
# ok (value, message) inner
Tests if value is truthy, it is equivalent to assert.equal(true, !!value, message);
Arguments:
value
:message
: