Skip to content

assertcheck v1.0.0


assertcheck / assert / not

Function: not()

ts
function not(fn, ...args): void;

Defined in: src/assert.ts:1942

Inverts any assertion — passes only if the inner assertion throws.

Parameters

ParameterTypeDescription
fn(...args) => voidAny assertion function from this module.
...argsunknown[]Arguments to forward to the assertion function.

Returns

void

Remarks

This is the only negation API in the library. Instead of duplicating every assertion as notEqual, notEmpty, etc., wrap any assertion in not().

Example

ts
// assert that two values are NOT equal
assert.not(assert.equal, user.role, "admin")

// assert that the array does NOT contain "FATAL"
assert.not(assert.includes, errors, "FATAL")

// assert the object does NOT have a forbidden key
assert.not(assert.hasKey, patch, "id")

Released under the Apache 2.0 License. Built by Vagabond Studio — senior-only for growing companies.