The Assert object provides functions to test JavaScript values against known and expected results. Whenever a comparison (assertion) fails, an error is thrown.
_formatMessagecustomMessage
defaultMessage
Formats a message so that it can contain the original assertion message in addition to the custom message.
The final error message, containing either or both.
_getCountReturns the number of assertions that have been performed.
_incrementIncrements the number of assertions that have been performed.
_resetResets the number of assertions that have been performed to 0.
areEqualexpected
actual
message
Asserts that a value is equal to another. This uses the double equals sign so type coercion may occur.
areNotEqualunexpected
actual
message
Asserts that a value is not equal to another. This uses the double equals sign so type coercion may occur.
areNotSameunexpected
actual
message
Asserts that a value is not the same as another. This uses the triple equals sign so no type coercion may occur.
areSameexpected
actual
message
Asserts that a value is the same as another. This uses the triple equals sign so no type coercion may occur.
failmessage
Forces an assertion error to occur.
message
String
(Optional) The message to display with the failure.
isArrayactual
message
Asserts that a value is an array.
isBooleanactual
message
Asserts that a value is a Boolean.
isFalseactual
message
Asserts that a value is false. This uses the triple equals sign so no type coercion may occur.
isFunctionactual
message
Asserts that a value is a function.
isInstanceOfexpected
actual
message
Asserts that a value is an instance of a particular object. This may return incorrect results when comparing objects from one frame to constructors in another frame. For best results, don't use in a cross-frame manner.
isNaNactual
message
Asserts that a value is not a number.
isNotNaNactual
message
Asserts that a value is not the special NaN value.
isNotNullactual
message
Asserts that a value is not null. This uses the triple equals sign so no type coercion may occur.
isNotUndefinedactual
message
Asserts that a value is not undefined. This uses the triple equals sign so no type coercion may occur.
isNullactual
message
Asserts that a value is null. This uses the triple equals sign so no type coercion may occur.
isNumberactual
message
Asserts that a value is a number.
isObjectactual
message
Asserts that a value is an object.
isStringactual
message
Asserts that a value is a string.
isTrueactual
message
Asserts that a value is true. This uses the triple equals sign so no type coercion may occur.
isTypeOfexpectedType
actualValue
message
Asserts that a value is of a particular type.
isUndefinedactual
message
Asserts that a value is undefined. This uses the triple equals sign so no type coercion may occur.
passA marker that the test should pass.
throwsErrorexpectedError
method
message
Asserts that executing a particular method should throw an error of a specific type. This is a replacement for _should.error.
expectedError
String | Function | Object
If a string, this is the error message that the error must have; if a function, this is the constructor that should have been used to create the thrown error; if an object, this is an instance of a particular error type with a specific error message (both must match).
method
Function
The method to execute that should throw the error.
message
String
(Optional) The message to display if the assertion fails.
_assertsThe number of assertions performed.