assert

assert module

Assertion test module, if the test value is false, then return an error, the error behavior can be set to continue or return error result.

Usage:

1
var assert = require('assert');

Static Function

Function

the test value is true, or if it is false, the assertion fails

1
assert.Function(actual,msg);

Parameter Usage:

ok

the test value is false, or if it is true, the assertion fails

1
assert.ok(actual,msg);

Parameter Usage:

notOk

the test value is true, or if it is false, the assertion fails

1
assert.notOk(actual,msg);

Parameter Usage:

equal

The test value is equal to the expected value, otherwise the assertion fails

1
assert.equal(actual,expected,msg);

Parameter Usage:

notEqual

Test values do not equal expectations, if the value is equal, the assertion is invalid

1
assert.notEqual(actual,expected,msg);

Parameter Usage:

strictEqual

The test value is strictly equal to the expected value, otherwise the assertion fails

1
assert.strictEqual(actual,expected,msg);

Parameter Usage:

notStrictEqual

The test value is not strictly equal to the expected value, and the assertion fails if it is equal

1
assert.notStrictEqual(actual,expected,msg);

Parameter Usage:

deepEqual

The test value is deeply equal to the expected value, otherwise the assertion fails

1
assert.deepEqual(actual,expected,msg);

Parameter Usage:

notDeepEqual

The test value is not deeply equal to the expected value, otherwise the assertion fails

1
assert.notDeepEqual(actual,expected,msg);

Parameter Usage:

closeTo

The test value is approximately equal to the expected value, otherwise the assertion fails

1
assert.closeTo(actual,expected,delta,msg);

Parameter Usage:

notCloseTo

The test value does not approximate the expected value, otherwise the assertion fails

1
assert.notCloseTo(actual,expected,delta,msg);

Parameter Usage:

lessThan

The test value is less than the expected value, assertion fails when it is greater or equal to the expected value

1
assert.lessThan(actual,expected,msg);

Parameter Usage:

notLessThan

The test value is not less than the expected value, assertion fails when it is less to the expected value

1
assert.notLessThan(actual,expected,msg);

Parameter Usage:

greaterThan

The test value is greater than the expected value, the assertion fails when it is less or equal to the expected value

1
assert.greaterThan(actual,expected,msg);

Parameter Usage:

notGreaterThan

The test value is not greater than the expected value,greater means the assertion fails

1
assert.notGreaterThan(actual,expected,msg);

Parameter Usage:

exist

The test variable exists. If it is false, the assertion fails

1
assert.exist(actual,msg);

Parameter Usage:

notExist

The test variable does not exist. If it is true, the assertion fails

1
assert.notExist(actual,msg);

Parameter Usage:

isTrue

The test value is Boolean true, otherwise the assertion fails

1
assert.isTrue(actual,msg);

Parameter Usage:

isNotTrue

The test value is not Boolean true, otherwise the assertion fails

1
assert.isNotTrue(actual,msg);

Parameter Usage:

isFalse

The test value is Boolean flase, otherwise the assertion fails

1
assert.isFalse(actual,msg);

Parameter Usage:

isNotFalse

The test value is not Boolean false, otherwise the assertion fails

1
assert.isNotFalse(actual,msg);

Parameter Usage:

isNull

The test value is Null, otherwise the assertion fails

1
assert.isNull(actual,msg);

Parameter Usage:

isNotNull

The test value is not Null, otherwise the assertion fails

1
assert.isNotNull(actual,msg);

Parameter Usage:

isUndefined

The test value is undefined, otherwise the assertion fails

1
assert.isUndefined(actual,msg);

Parameter Usage:

isDefined

The test value is not undefined, otherwise the assertion fails

1
assert.isDefined(actual,msg);

Parameter Usage:

isFunction

The test value is a function, otherwise the assertion fails

1
assert.isFunction(actual,msg);

Parameter Usage:

isNotFunction

The test value is not a function, otherwise the assertion fails

1
assert.isNotFunction(actual,msg);

Parameter Usage:

isObject

The test value is an object, otherwise the assertion fails

1
assert.isObject(actual,msg);

Parameter Usage:

isNotObject

The test value is not an object, otherwise the assertion fails

1
assert.isNotObject(actual,msg);

Parameter Usage:

isArray

The test value is an array, otherwise the assertion fails

1
assert.isArray(actual,msg);

Parameter Usage:

isNotArray

The test value is not an array, otherwise the assertion fails

1
assert.isNotArray(actual,msg);

Parameter Usage:

isString

The test value is a string, otherwise the assertion fails

1
assert.isString(actual,msg);

Parameter Usage:

isNotString

The test value is not a string, otherwise the assertion fails

1
assert.isNotString(actual,msg);

Parameter Usage:

isNumber

The test value is a number, otherwise the assertion fails

1
assert.isNumber(actual,msg);

Parameter Usage:

isNotNumber

The test value is not a number, otherwise the assertion fails

1
assert.isNotNumber(actual,msg);

Parameter Usage:

isBoolean

The test value is a Boolean, otherwise the assertion fails

1
assert.isBoolean(actual,msg);

Parameter Usage:

isNotBoolean

The test value is not a Boolean, otherwise the assertion fails

1
assert.isNotBoolean(actual,msg);

Parameter Usage:

typeOf

The test value is a given type, otherwise the assertion fails

1
assert.typeOf(actual,type,msg);

Parameter Usage:

notTypeOf

The test value is not a given type, otherwise the assertion fails

1
assert.notTypeOf(actual,type,msg);

Parameter Usage:

property

The test value includes given property, otherwise the assertion fails

1
assert.property(object,prop,msg);

Parameter Usage:

notProperty

The test value does not includes given property, otherwise the assertion fails

1
assert.notProperty(object,prop,msg);

Parameter Usage:

deepProperty

The deep test object contains the specified property, otherwise the assertion fails

1
assert.deepProperty(object,prop,msg);

Parameter Usage:

notDeepProperty

The deep test object does not contain the specified property, or the assertion fails

1
assert.notDeepProperty(object,prop,msg);

Parameter Usage:

propertyVal

The value of the property specified in the test object is a given value, otherwise the assertion fails

1
assert.propertyVal(object,prop,value,msg);

Parameter Usage:

propertyNotVal

The value of the property specified in the test object is not a given value, otherwise the assertion fails

1
assert.propertyNotVal(object,prop,value,msg);

Parameter Usage:

deepPropertyVal

The value of the property specified in the deep test object is a given value, otherwise the assertion fails

1
assert.deepPropertyVal(object,prop,value,msg);

Parameter Usage:

deepPropertyNotVal

The value of the property specified in the deep test object is not a given value, otherwise the assertion fails

1
assert.deepPropertyNotVal(object,prop,value,msg);

Parameter Usage:

throws

Testing a given code returns an error and assertion fails if it is not returned

1
assert.throws(Function block,msg);

Parameter Usage:

doesNotThrow

The test given code does not return an error, and the assertion fails if returns

1
assert.doesNotThrow(Function block,msg);

Parameter Usage:

ifError

If the parameter is true,then return

1
assert.ifError(object);

Parameter Usage: