Provides operations for asserting that all conditions in a chain are met.
This operation allows you to assert that all specified conditions are true for the target value. It is useful for combining multiple assertions into a single chain, ensuring that all conditions must pass.
A new IAssertInst with the value of the property assertion.
Provides operations for asserting that any condition in a chain is met.
This operation allows you to assert that at least one of the specified conditions is true for the target value. It is useful for combining multiple assertions into a single chain, ensuring that at least one condition must pass.
Provides operations for containment checks.
This operation allows you to assert that the target value contains the specified value(s). It is useful for verifying that an array, string, or object contains certain elements or properties.
import { assert } from "@nevware21/tripwire";
const arr = [1, 2, 3];
const str = "hello darkness my old friend";
const obj = { a: 1, b: 2, c: 3 };
assert(arr).contain(2); // Passes
assert(str).contain("darkness"); // Passes
assert(obj).contain.all.keys('a', 'b'); // Passes
assert(arr).contain(4); // Fails
assert(str).contain("planet"); // Fails
assert(obj).contain.all.keys('a', 'd'); // Fails
Provides operations for containment checks.
This operation allows you to assert that the target value contains the specified value(s). It is useful for verifying that an array, string, or object contains certain elements or properties.
import { assert } from "@nevware21/tripwire";
const arr = [1, 2, 3];
const str = "hello darkness my old friend";
const obj = { a: 1, b: 2, c: 3 };
assert(arr).contains(2); // Passes
assert(str).contains("darkness"); // Passes
assert(obj).contains.all.keys('a', 'b'); // Passes
assert(arr).contains(4); // Fails
assert(str).contains("planet"); // Fails
assert(obj).contains.all.keys('a', 'd'); // Fails
This operation provides access to operations that will deeplyallows you to assert that the target value deeply equals the expected value. It is useful for comparing objects, arrays, and other complex structures.
Performs an equality check between the actual
and expected
values, throwing an
AssertionFailure
with the given message when the actual
value is not equal to
the expected
value. The default equality check is a loose (==
) equality check,
to perform a strict equality check (===
), use the IStrictlyOp.equal
(strictly.equal
) operations and when comparing complex objects, use the deep
equality operations provided by the IDeepOp.equal (deep.equal
) operations or
(deep.strictly.equal
) for deep strict equality checks.
IStrictlyOp.eq (strictly.eq
) operations.
assert.eq(1, 1); // Passes
assert.eq("a", "a"); // Passes
assert.eq(true, true); // Passes
assert.eq(false, false); // Passes
assert.eq(null, null); // Passes
assert.eq(undefined, undefined); // Passes
assert.eq(0, 0); // Passes
assert.eq(-0, -0); // Passes
assert.eq(+0, +0); // Passes
assert.eq(0n, 0n); // Passes
assert.eq("", ""); // Passes
assert.eq(Symbol(), Symbol()); // Passes
assert.eq([], []); // Throws AssertionError
assert.eq([1, 2], [1, 2]); // Throws AssertionError
Performs an equality check between the actual
and expected
values, throwing an
AssertionFailure
with the given message when the actual
value is not equal to
the expected
value. The default equality check is a loose (==
) equality check,
to perform a strict equality check (===
), use the IStrictlyOp.equal
(strictly.equal
) operations and when comparing complex objects, use the deep
equality operations provided by the IDeepOp.equal (deep.equal
) operations or
(deep.strictly.equal
) for deep strict equality checks.
assert.equal(1, 1); // Passes
assert.equal("a", "a"); // Passes
assert.equal(true, true); // Passes
assert.equal(false, false); // Passes
assert.equal(null, null); // Passes
assert.equal(undefined, undefined); // Passes
assert.equal(0, 0); // Passes
assert.equal(-0, -0); // Passes
assert.equal(+0, +0); // Passes
assert.equal(0n, 0n); // Passes
assert.equal("", ""); // Passes
assert.equal(Symbol(), Symbol()); // Passes
assert.equal([], []); // Throws AssertionError
assert.equal([1, 2], [1, 2]); // Throws AssertionError
Performs an equality check between the actual
and expected
values, throwing an
AssertionFailure
with the given message when the actual
value is not equal to
the expected
value. The default equality check is a loose (==
) equality check,
to perform a strict equality check (===
), use the IStrictlyOp.equal
(strictly.equal
) operations and when comparing complex objects, use the deep
equality operations provided by the IDeepOp.equal (deep.equal
) operations or
(deep.strictly.equal
) for deep strict equality checks.
assert.equals(1, 1); // Passes
assert.equals("a", "a"); // Passes
assert.equals(true, true); // Passes
assert.equals(false, false); // Passes
assert.equals(null, null); // Passes
assert.equals(undefined, undefined); // Passes
assert.equals(0, 0); // Passes
assert.equals(-0, -0); // Passes
assert.equals(+0, +0); // Passes
assert.equals(0n, 0n); // Passes
assert.equals("", ""); // Passes
assert.equals(Symbol(), Symbol()); // Passes
assert.equals([], []); // Throws AssertionError
assert.equals([1, 2], [1, 2]); // Throws AssertionError
Provides operations for checking whether the target value has a specific property.
This operation allows you to assert that the target value has the specified property. It is useful for verifying that an object has a certain property.
Provides operations for inclusion checks.
This operation allows you to assert that the target value includes the specified value(s). It is useful for verifying that an array, string, or object contains certain elements or properties.
import { assert } from "@nevware21/tripwire";
const arr = [1, 2, 3];
const str = "hello darkness my old friend";
const obj = { a: 1, b: 2, c: 3 };
assert(arr).include(2); // Passes
assert(str).include("darkness"); // Passes
assert(obj).include.all.keys('a', 'b'); // Passes
assert(arr).include(4); // Fails
assert(str).include("planet"); // Fails
assert(obj).include.all.keys('a', 'd'); // Fails
Provides operations for inclusion checks.
This operation allows you to assert that the target value includes the specified value(s). It is useful for verifying that an array, string, or object contains certain elements or properties.
import { assert } from "@nevware21/tripwire";
const arr = [1, 2, 3];
const str = "hello darkness my old friend";
const obj = { a: 1, b: 2, c: 3 };
assert(arr).includes(2); // Passes
assert(str).includes("darkness"); // Passes
assert(obj).includes.all.keys('a', 'b'); // Passes
assert(arr).includes(4); // Fails
assert(str).includes("planet"); // Fails
assert(obj).includes.all.keys('a', 'd'); // Fails
Provides operations for type and equality checks.
This operation allows you to assert that the target value is of the specified type. It is useful for verifying the type of a value, such as a number, string, or object.
Negates any performed evaluations that are performed in the assertion chain.
This operation applies a stateful change to the evaluation chain, meaning
that subsequent operations that would normally fail will pass without the need
for them to "implement" any knowledge about the not
operation. You may call
not
multiple times to negate the negation.
Provides operations for ownership checks.
This operation allows you to assert that the target object has its own property with the specified name. It is useful for verifying that an object has a property directly on itself, rather than inheriting it from its prototype chain.
Provides operations for strict equality checks.
This operation allows you to assert that the target value is strictly equal to the expected value. It is useful for comparing values without any type coercion.
A new IAssertInst with the value of the property assertion.
Asserts that the value is a function that when executed will throw an error.
AssertionFailure - If the function does not throw an error.
AssertionError - If the error thrown does not match the expected error.
AssertionError - If the error message does not match the expected message.
Provides syntatic operations for accessing whether the target is of a specific type, has a specific property, or is strictly equal to a specific value.
A new IAssertInst with the value of the property assertion.
Throws an AssertionFailure exception with the given message and optional
details which are obtained via the getDetails
function.
Optional
msg: MsgSourceThe message to display.
Optional
details: anyThe details (props) to include in the error
AssertionFailure always
Generic failure that throws an AssertionFailure exception with the given
message and optional details which are obtained via the getDetails
function.
The actual value that was expected
The expected value that was not found
Optional
failMsg: MsgSourceThe message to display.
Optional
operator: stringThe optional operator used in the comparison
AssertionFailure always
Throws an AssertionError exception with the given message and optional
details which are obtained via the getDetails
function.
The message to display.
Optional
details: anyThe details (props) to include in the error
AssertionFailure always
Determines whether an object has a property with the specified name.
Optional
evalMsg: MsgSourceOptional
evalMsg: MsgSourceOptional
evalMsg: MsgSourceOptional
evalMsg: MsgSource
Represents an interface that provides assertion operations based on the property operations.
Template: R
The type of the result of the operation.