@fordi-org/assert
v1.0.2
Published
Wrapper around node:assert for custom assertions
Downloads
6
Readme
@fordi-org/assert
A wrapper around node:assert where I keep custom assertions.
sameType
Assert that two items are the same type.
assert.sameType(actual, expected, message)
sameLength
Assert that two objects have the same length.
assert.sameLength(actual, expected, message);
closeTo
Assert that two numbers are close to one another within some tolerance.
assert.closeTo(actual, expected, epsilon, message);
The default tolerance is an epsilon of 1e-15; you can change the default by setting assert.closeTo.defaultEpsilon
.
deeply
Create an assertion that applies recursively to objects / arrays.
const deepCustomAssertion = deeply(customAssertion);
deepCloseTo
assert.deepCloseTo(actual, expected, epsilon, message);
Same as assert.closeTo, but recursive.