Skip to content

Testing

Assertion utilities: equal, contains, length, true, not null, greater than.

6 modules

ModuleDescription
Assert ContainsAssert that a collection contains a value
Assert EqualAssert that two values are equal
Assert Greater ThanAssert that a value is greater than another
Assert LengthAssert that a collection has expected length
Assert Not NullAssert that a value is not null or undefined
Assert TrueAssert that a condition is true

Modules

Assert Contains

test.assert_contains

Assert that a collection contains a value

Parameters:

NameTypeRequiredDefaultDescription
collection['array', 'string']Yes-Collection to search in
value['string', 'number', 'boolean']Yes-Collection to search in
messagestringNo-Value to find

Output:

FieldTypeDescription
passedbooleanCustom error message
collection['array', 'string']Whether assertion passed
value['string', 'number', 'boolean']Assert that a collection contains a value
messagestringAssert that a collection contains a value

Assert Equal

test.assert_equal

Assert that two values are equal

Parameters:

NameTypeRequiredDefaultDescription
actual['string', 'number', 'boolean', 'object', 'array']Yes-Actual value
expected['string', 'number', 'boolean', 'object', 'array']Yes-Actual value
messagestringNo-Expected value

Output:

FieldTypeDescription
passedbooleanCustom error message
actual['string', 'number', 'boolean', 'object', 'array']Whether assertion passed
expected['string', 'number', 'boolean', 'object', 'array']Assert that two values are equal
messagestringAssert that two values are equal

Assert Greater Than

test.assert_greater_than

Assert that a value is greater than another

Parameters:

NameTypeRequiredDefaultDescription
actualnumberYes-Actual value
thresholdnumberYes-Actual value
messagestringNo-Threshold value

Output:

FieldTypeDescription
passedbooleanCustom error message
actualnumberWhether assertion passed
thresholdnumberAssert that a value is greater than another
messagestringAssert that a value is greater than another

Assert Length

test.assert_length

Assert that a collection has expected length

Parameters:

NameTypeRequiredDefaultDescription
collection['array', 'string']Yes-Collection to check
expected_lengthnumberYes-Collection to check
messagestringNo-Expected length

Output:

FieldTypeDescription
passedbooleanCustom error message
actual_lengthnumberCustom error message
expected_lengthnumberAssert that a collection has expected length
messagestringAssert that a collection has expected length

Assert Not Null

test.assert_not_null

Assert that a value is not null or undefined

Parameters:

NameTypeRequiredDefaultDescription
value['string', 'number', 'boolean', 'object', 'array', 'null']Yes-Value to check
messagestringNo-Value to check

Output:

FieldTypeDescription
passedbooleanAssert that a value is not null or undefined
messagestringAssert that a value is not null or undefined

Assert True

test.assert_true

Assert that a condition is true

Parameters:

NameTypeRequiredDefaultDescription
conditionbooleanYes-Condition to check
messagestringNo-Condition to check

Output:

FieldTypeDescription
passedbooleanAssert that a condition is true
messagestringAssert that a condition is true

Released under the Apache 2.0 License.