Assertion library for JavaScript.
npm i bare-assert
const assert = require('bare-assert')
assert(1 + 1 === 2, 'sum should be correct')
assert.equal(1, 1)
assert.notEqual(1, 2)Throws an AssertionError unless value is truthy. If message is an Error instance, it is thrown directly instead of being wrapped in an AssertionError.
An Error subclass thrown by all assertions on failure. Instances have the following properties:
The actual value passed to the assertion, if any.
The expected value passed to the assertion, if any.
The name of the operator used by the assertion that failed, such as '==' or 'strictEqual'.
If no message is provided to AssertionError, one is generated from actual, expected, and operator.
Throws an AssertionError unconditionally. Defaults message to 'Failed' if not provided.
Throws an AssertionError unless value is truthy. Equivalent to assert().
Throws an AssertionError if value is truthy.
Throws an AssertionError unless actual == expected, using the == operator. NaN is treated as equal to NaN.
Throws an AssertionError unless actual != expected, using the != operator. NaN is treated as equal to NaN.
Throws an AssertionError unless actual and expected are the same value, as determined by Object.is().
Throws an AssertionError unless actual and expected are not the same value, as determined by Object.is().
Throws an AssertionError unless actual and expected are the same value, recursively.
Throws an AssertionError unless actual and expected are not the same value, recursively.
Throws an AssertionError unless actual is a string that matches regexp.
Throws an AssertionError unless actual is a string that does not match regexp.
Throws an AssertionError unless actual is undefined or null.
Apache-2.0