Module assert
Assertion library covering the CommonJS Unit Testing specification and a few additional convenience methods.
Functions
- deepEqual(actual, expected)
- equal(actual, expected)
- fail(options)
- isFalse(val)
- isNaN(val)
- isNotNaN(val)
- isNotNull(val)
- isNotUndefined(val)
- isNull(val)
- isTrue(val)
- isUndefined(val)
- matches(value, expr)
- notDeepEqual(actual, expected)
- notEqual(actual, expected)
- notStrictEqual(actual, expected)
- ok(value)
- strictEqual(actual, expected)
- stringContains(value, pattern)
- throws(func, expectedError)
ArgumentsError (message)
Creates a new ArgumentsError instance
Parameters
String | message | The exception message |
Returns
A newly created ArgumentsError instance |
ArgumentsError.prototype. message
ArgumentsError.prototype. stackTrace
AssertionError (options)
Constructs a new AssertionError instance
Parameters
Object | options | An object containing error details |
AssertionError.prototype. actual
AssertionError.prototype. expected
AssertionError.prototype. message
AssertionError.prototype. name
AssertionError.prototype. stackTrace
deepEqual (actual, expected)
Checks if the values passed as arguments are deep equal
Parameters
Object | actual | The actual value |
Object | expected | The expected value |
Throws
equal (actual, expected)
Checks if the values passed as arguments are equal.
Parameters
Object | actual | The actual value |
Object | expected | The expected value |
Throws
fail (options)
Basic failure method
Parameters
Object|String | options | An object containing optional "message", "actual" and "expected" properties, or alternatively a message string |
Throws
isFalse (val)
Checks if the value passed as argument is boolean false.
Parameters
Object | val | The value that should be boolean false. |
Throws
isNaN (val)
Checks if the value passed as argument is NaN.
Parameters
Object | val | The value that should be NaN. |
Throws
isNotNaN (val)
Checks if the value passed as argument is not NaN.
Parameters
Object | val | The value that should be not NaN. |
Throws
isNotNull (val)
Checks if the value passed as argument is not null.
Parameters
Object | val | The value that should be not null. |
Throws
isNotUndefined (val)
Checks if the value passed as argument is not undefined.
Parameters
Object | val | The value that should be not undefined. |
Throws
isNull (val)
Checks if the value passed as argument is null.
Parameters
Object | val | The value that should be null. |
Throws
isTrue (val)
Checks if the value passed as argument is boolean true.
Parameters
Object | val | The value that should be boolean true. |
Throws
isUndefined (val)
Checks if the value passed as argument is undefined.
Parameters
Object | val | The value that should be undefined. |
Throws
matches (value, expr)
Checks if the regular expression matches the string.
Parameters
String | value | The string that should contain the regular expression pattern |
RegExp | expr | The regular expression that should match the value |
Throws
notDeepEqual (actual, expected)
Checks if the values passed as arguments are not deep equal
Parameters
Object | actual | The actual value |
Object | expected | The expected value |
Throws
notEqual (actual, expected)
Checks if the values passed as arguments are not equal.
Parameters
Object | actual | The actual value |
Object | expected | The expected value |
Throws
notStrictEqual (actual, expected)
Checks if the values passed as arguments are not strictly equal
Parameters
Object | actual | The actual value |
Object | expected | The expected value |
Throws
ok (value)
Checks if the value passed as argument is truthy.
Parameters
Object | value | The value to check for truthiness |
Throws
strictEqual (actual, expected)
Checks if the values passed as arguments are strictly equal
Parameters
Object | actual | The actual value |
Object | expected | The expected value |
Throws
stringContains (value, pattern)
Checks if the value passed as argument contains the pattern specified.
Parameters
String | value | The string that should contain the pattern |
String | pattern | The string that should be contained |
Throws
throws (func, expectedError)
Checks if the function passed as argument throws a defined exception.
Parameters
Object | func | The function to call |
Object | expectedError | Optional object expected to be thrown when executing the function |