@nevware21/tripwire - v0.1.4
    Preparing search index...

    Interface IAssertClass<AssertInst>

    The IAssert interface defines the methods for performing assertions. This interface is used to ensure that certain conditions hold true during runtime. If an assertion fails, an AssertionFailure is thrown with an optional message.

    0.1.0

    interface IAssertClass<AssertInst extends IAssertInst = IAssertInst> {
        _$lastContext: IScopeContext;
        approximately(
            actual: number,
            expected: number,
            delta: number,
            initMsg?: MsgSource,
        ): AssertInst;
        changes(fn: () => void, getter: () => any, initMsg?: MsgSource): AssertInst;
        changes<T = any>(
            fn: () => void,
            target: T,
            prop: keyof T,
            initMsg?: MsgSource,
        ): AssertInst;
        changesButNotBy(
            fn: () => void,
            getter: () => any,
            delta: number,
            initMsg?: MsgSource,
        ): AssertInst;
        changesButNotBy<T>(
            fn: () => void,
            target: T,
            prop: keyof T,
            delta: number,
            initMsg?: MsgSource,
        ): AssertInst;
        changesBy(
            fn: () => void,
            getter: () => any,
            delta: number,
            initMsg?: MsgSource,
        ): AssertInst;
        changesBy<T>(
            fn: () => void,
            target: T,
            prop: keyof T,
            delta: number,
            initMsg?: MsgSource,
        ): AssertInst;
        closeTo(
            actual: number,
            expected: number,
            delta: number,
            initMsg?: MsgSource,
        ): AssertInst;
        decreases(
            fn: () => void,
            getter: () => any,
            initMsg?: MsgSource,
        ): AssertInst;
        decreases<T>(
            fn: () => void,
            target: T,
            prop: keyof T,
            initMsg?: MsgSource,
        ): AssertInst;
        decreasesButNotBy(
            fn: () => void,
            getter: () => any,
            delta: number,
            initMsg?: MsgSource,
        ): AssertInst;
        decreasesButNotBy<T>(
            fn: () => void,
            target: T,
            prop: keyof T,
            delta: number,
            initMsg?: MsgSource,
        ): AssertInst;
        decreasesBy(
            fn: () => void,
            getter: () => any,
            delta: number,
            initMsg?: MsgSource,
        ): AssertInst;
        decreasesBy<T>(
            fn: () => void,
            target: T,
            prop: keyof T,
            delta: number,
            initMsg?: MsgSource,
        ): AssertInst;
        deepEqual<T>(actual: T, expected: unknown, initMsg?: MsgSource): AssertInst;
        deepEquals<T>(
            actual: T,
            expected: unknown,
            initMsg?: MsgSource,
        ): AssertInst;
        deepNestedInclude<T>(
            value: T,
            expected: any,
            initMsg?: MsgSource,
        ): AssertInst;
        deepNestedProperty<T>(
            target: T,
            path: string,
            value?: any,
            initMsg?: MsgSource,
        ): AssertInst;
        deepOwnInclude<T>(value: T, expected: any, initMsg?: MsgSource): AssertInst;
        deepStrictEqual<T>(
            actual: T,
            expected: unknown,
            initMsg?: MsgSource,
        ): AssertInst;
        deepStrictEquals<T>(
            actual: T,
            expected: unknown,
            initMsg?: MsgSource,
        ): AssertInst;
        deepSubsequence<T>(
            actual: ArrayLikeOrSizedIterable<T>,
            expected: ArrayLikeOrSizedIterable<T>,
            initMsg?: MsgSource,
        ): AssertInst;
        doesNotChange(
            fn: () => void,
            getter: () => any,
            initMsg?: MsgSource,
        ): AssertInst;
        doesNotChange<T>(
            fn: () => void,
            target: T,
            prop: keyof T,
            initMsg?: MsgSource,
        ): AssertInst;
        doesNotDecrease(
            fn: () => void,
            getter: () => any,
            initMsg?: MsgSource,
        ): AssertInst;
        doesNotDecrease<T>(
            fn: () => void,
            target: T,
            prop: keyof T,
            initMsg?: MsgSource,
        ): AssertInst;
        doesNotHaveAllDeepKeys(
            target: any,
            keys: any,
            initMsg?: MsgSource,
        ): AssertInst;
        doesNotHaveAllKeys(target: any, keys: any, initMsg?: MsgSource): AssertInst;
        doesNotHaveAnyDeepKeys(
            target: any,
            keys: any,
            initMsg?: MsgSource,
        ): AssertInst;
        doesNotHaveAnyKeys(target: any, keys: any, initMsg?: MsgSource): AssertInst;
        doesNotIncrease(
            fn: () => void,
            getter: () => any,
            initMsg?: MsgSource,
        ): AssertInst;
        doesNotIncrease<T>(
            fn: () => void,
            target: T,
            prop: keyof T,
            initMsg?: MsgSource,
        ): AssertInst;
        doesNotThrow(
            fn: () => void,
            errorLike?: Error | ErrorConstructor,
            msgMatch?: string | RegExp,
            initMsg?: MsgSource,
        ): AssertInst;
        doesNotThrow(
            fn: () => void,
            msgMatch?: string | RegExp,
            initMsg?: MsgSource,
        ): AssertInst;
        endsWithDeepMembers<T>(
            actual: ArrayLikeOrSizedIterable<T>,
            expected: ArrayLikeOrSizedIterable<T>,
            initMsg?: MsgSource,
        ): AssertInst;
        endsWithMembers<T>(
            actual: ArrayLikeOrSizedIterable<T>,
            expected: ArrayLikeOrSizedIterable<T>,
            initMsg?: MsgSource,
        ): AssertInst;
        equal<T>(actual: T, expected: unknown, initMsg?: MsgSource): AssertInst;
        equals<T>(actual: T, expected: unknown, initMsg?: MsgSource): AssertInst;
        exists(value: any, initMsg?: MsgSource): AssertInst;
        fail(initMsg?: MsgSource): never;
        fail(
            actual: any,
            expected: any,
            failMsg?: MsgSource,
            operator?: string,
        ): never;
        fatal(initMsg?: MsgSource): never;
        hasAllDeepKeys(target: any, keys: any, initMsg?: MsgSource): AssertInst;
        hasAllKeys(target: any, keys: any, initMsg?: MsgSource): AssertInst;
        hasAnyDeepKeys(target: any, keys: any, initMsg?: MsgSource): AssertInst;
        hasAnyKeys(target: any, keys: any, initMsg?: MsgSource): AssertInst;
        hasDeepOwnProperty<T>(
            target: T,
            name: string,
            value: any,
            initMsg?: MsgSource,
        ): AssertInst;
        hasDeepProperty<T>(
            target: T,
            name: string,
            value: any,
            initMsg?: MsgSource,
        ): AssertInst;
        hasOwnProperty<T>(
            target: T,
            name: string,
            value?: any,
            initMsg?: MsgSource,
        ): AssertInst;
        hasProperty<T>(
            target: T,
            name: string,
            value?: any,
            initMsg?: MsgSource,
        ): AssertInst;
        ifError(value: any, initMsg?: MsgSource): AssertInst;
        includeDeepMembers<T>(
            superset: ArrayLikeOrSizedIterable<T>,
            subset: ArrayLikeOrSizedIterable<T>,
            initMsg?: MsgSource,
        ): AssertInst;
        includeDeepOrderedMembers<T>(
            superset: ArrayLikeOrSizedIterable<T>,
            subset: ArrayLikeOrSizedIterable<T>,
            initMsg?: MsgSource,
        ): AssertInst;
        includeMembers<T>(
            superset: ArrayLikeOrSizedIterable<T>,
            subset: ArrayLikeOrSizedIterable<T>,
            initMsg?: MsgSource,
        ): AssertInst;
        includeOrderedMembers<T>(
            superset: ArrayLikeOrSizedIterable<T>,
            subset: ArrayLikeOrSizedIterable<T>,
            initMsg?: MsgSource,
        ): AssertInst;
        includes<T>(value: T, match: any, initMsg?: MsgSource): AssertInst;
        increases(
            fn: () => void,
            getter: () => any,
            initMsg?: MsgSource,
        ): AssertInst;
        increases<T>(
            fn: () => void,
            target: T,
            prop: keyof T,
            initMsg?: MsgSource,
        ): AssertInst;
        increasesButNotBy(
            fn: () => void,
            getter: () => any,
            delta: number,
            initMsg?: MsgSource,
        ): AssertInst;
        increasesButNotBy<T>(
            fn: () => void,
            target: T,
            prop: keyof T,
            delta: number,
            initMsg?: MsgSource,
        ): AssertInst;
        increasesBy(
            fn: () => void,
            getter: () => any,
            delta: number,
            initMsg?: MsgSource,
        ): AssertInst;
        increasesBy<T>(
            fn: () => void,
            target: T,
            prop: keyof T,
            delta: number,
            initMsg?: MsgSource,
        ): AssertInst;
        isAbove(
            value: number | Date,
            expected: number | Date,
            initMsg?: MsgSource,
        ): AssertInst;
        isArray(value: any, initMsg?: MsgSource): AssertInst;
        isAtLeast(
            value: number | Date,
            expected: number | Date,
            initMsg?: MsgSource,
        ): AssertInst;
        isAtMost(
            value: number | Date,
            expected: number | Date,
            initMsg?: MsgSource,
        ): AssertInst;
        isBelow(
            value: number | Date,
            expected: number | Date,
            initMsg?: MsgSource,
        ): AssertInst;
        isBoolean(value: any, initMsg?: MsgSource): AssertInst;
        isEmpty(value: any, initMsg?: MsgSource): AssertInst;
        isError<T>(
            value: T,
            errorLike?: Error | ErrorConstructor,
            initMsg?: MsgSource,
        ): AssertInst;
        isExtensible(value: any, initMsg?: MsgSource): AssertInst;
        isFalse(value: unknown, initMsg?: MsgSource): AssertInst;
        isFinite(value: any, initMsg?: MsgSource): AssertInst;
        isFrozen(value: any, initMsg?: MsgSource): AssertInst;
        isFunction(value: any, initMsg?: MsgSource): AssertInst;
        isInstanceOf(
            value: any,
            constructor: Function,
            initMsg?: MsgSource,
        ): AssertInst;
        isIterable(value: any, initMsg?: MsgSource): AssertInst;
        isNaN(value: any, initMsg?: MsgSource): AssertInst;
        isNotAbove(
            value: number | Date,
            expected: number | Date,
            initMsg?: MsgSource,
        ): AssertInst;
        isNotArray(value: any, initMsg?: MsgSource): AssertInst;
        isNotAtLeast(
            value: number | Date,
            expected: number | Date,
            initMsg?: MsgSource,
        ): AssertInst;
        isNotAtMost(
            value: number | Date,
            expected: number | Date,
            initMsg?: MsgSource,
        ): AssertInst;
        isNotBelow(
            value: number | Date,
            expected: number | Date,
            initMsg?: MsgSource,
        ): AssertInst;
        isNotBoolean(value: any, initMsg?: MsgSource): AssertInst;
        isNotEmpty(value: any, initMsg?: MsgSource): AssertInst;
        isNotExtensible(value: any, initMsg?: MsgSource): AssertInst;
        isNotFalse(value: unknown, initMsg?: MsgSource): AssertInst;
        isNotFinite(value: any, initMsg?: MsgSource): AssertInst;
        isNotFrozen(value: any, initMsg?: MsgSource): AssertInst;
        isNotFunction(value: any, initMsg?: MsgSource): AssertInst;
        isNotInstanceOf(
            value: any,
            constructor: Function,
            initMsg?: MsgSource,
        ): AssertInst;
        isNotIterable(value: any, initMsg?: MsgSource): AssertInst;
        isNotNaN(value: any, initMsg?: MsgSource): AssertInst;
        isNotNull<T>(value: T, initMsg?: MsgSource): AssertInst;
        isNotNumber(value: any, initMsg?: MsgSource): AssertInst;
        isNotObject<T>(value: T, initMsg?: MsgSource): AssertInst;
        isNotOk<T>(value: T, initMsg?: MsgSource): AssertInst;
        isNotPlainObject<T>(value: T, initMsg?: MsgSource): AssertInst;
        isNotSealed(value: any, initMsg?: MsgSource): AssertInst;
        isNotString(value: any, initMsg?: MsgSource): AssertInst;
        isNotTrue(value: unknown, initMsg?: MsgSource): AssertInst;
        isNotUndefined<T>(value: T, initMsg?: MsgSource): AssertInst;
        isNotWithin(
            value: number | Date,
            start: number | Date,
            finish: number | Date,
            initMsg?: MsgSource,
        ): AssertInst;
        isNull<T>(value: T, initMsg?: MsgSource): AssertInst;
        isNumber(value: any, initMsg?: MsgSource): AssertInst;
        isObject<T>(value: T, initMsg?: MsgSource): AssertInst;
        isOk<T>(value: T, initMsg?: MsgSource): AssertInst;
        isPlainObject<T>(value: T, initMsg?: MsgSource): AssertInst;
        isSealed(value: any, initMsg?: MsgSource): AssertInst;
        isString(value: any, initMsg?: MsgSource): AssertInst;
        isTrue(value: unknown, initMsg?: MsgSource): AssertInst;
        isUndefined<T>(value: T, initMsg?: MsgSource): AssertInst;
        isWithin(
            value: number | Date,
            start: number | Date,
            finish: number | Date,
            initMsg?: MsgSource,
        ): AssertInst;
        lengthOf<T extends { length?: number } | { size?: number }>(
            object: T,
            length: number,
            initMsg?: MsgSource,
        ): AssertInst;
        match<T>(value: T, regexp: RegExp, initMsg?: MsgSource): AssertInst;
        nestedInclude<T>(value: T, expected: any, initMsg?: MsgSource): AssertInst;
        nestedProperty<T>(
            target: T,
            path: string,
            value?: any,
            initMsg?: MsgSource,
        ): AssertInst;
        notApproximately(
            actual: number,
            expected: number,
            delta: number,
            initMsg?: MsgSource,
        ): AssertInst;
        notChangesBy(
            fn: () => void,
            getter: () => any,
            delta: number,
            initMsg?: MsgSource,
        ): AssertInst;
        notChangesBy<T>(
            fn: () => void,
            target: T,
            prop: keyof T,
            delta: number,
            initMsg?: MsgSource,
        ): AssertInst;
        notCloseTo(
            actual: number,
            expected: number,
            delta: number,
            initMsg?: MsgSource,
        ): AssertInst;
        notDecreasesBy(
            fn: () => void,
            getter: () => any,
            delta: number,
            initMsg?: MsgSource,
        ): AssertInst;
        notDecreasesBy<T>(
            fn: () => void,
            target: T,
            prop: keyof T,
            delta: number,
            initMsg?: MsgSource,
        ): AssertInst;
        notDeepEqual<T>(actual: T, expected: T, initMsg?: MsgSource): AssertInst;
        notDeepEquals<T>(actual: T, expected: T, initMsg?: MsgSource): AssertInst;
        notDeepNestedInclude<T>(
            value: T,
            expected: any,
            initMsg?: MsgSource,
        ): AssertInst;
        notDeepNestedProperty<T>(
            target: T,
            path: string,
            value?: any,
            initMsg?: MsgSource,
        ): AssertInst;
        notDeepOwnInclude<T>(
            value: T,
            expected: any,
            initMsg?: MsgSource,
        ): AssertInst;
        notDeepSubsequence<T>(
            actual: ArrayLikeOrSizedIterable<T>,
            expected: ArrayLikeOrSizedIterable<T>,
            initMsg?: MsgSource,
        ): AssertInst;
        notEndsWithDeepMembers<T>(
            actual: ArrayLikeOrSizedIterable<T>,
            expected: ArrayLikeOrSizedIterable<T>,
            initMsg?: MsgSource,
        ): AssertInst;
        notEndsWithMembers<T>(
            actual: ArrayLikeOrSizedIterable<T>,
            expected: ArrayLikeOrSizedIterable<T>,
            initMsg?: MsgSource,
        ): AssertInst;
        notEqual<T>(actual: T, expected: T, initMsg?: MsgSource): AssertInst;
        notEquals<T>(actual: T, expected: T, initMsg?: MsgSource): AssertInst;
        notExists(value: any, initMsg?: MsgSource): AssertInst;
        notHasDeepOwnProperty<T>(
            target: T,
            name: string,
            value: any,
            initMsg?: MsgSource,
        ): AssertInst;
        notHasDeepProperty<T>(
            target: T,
            name: string,
            value: any,
            initMsg?: MsgSource,
        ): AssertInst;
        notHasOwnProperty<T>(
            target: T,
            name: string,
            value?: any,
            initMsg?: MsgSource,
        ): AssertInst;
        notHasProperty<T>(
            target: T,
            name: string,
            value?: any,
            initMsg?: MsgSource,
        ): AssertInst;
        notHaveAllDeepKeys(target: any, keys: any, initMsg?: MsgSource): AssertInst;
        notHaveAnyDeepKeys(target: any, keys: any, initMsg?: MsgSource): AssertInst;
        notIncludeDeepMembers<T>(
            superset: ArrayLikeOrSizedIterable<T>,
            subset: ArrayLikeOrSizedIterable<T>,
            initMsg?: MsgSource,
        ): AssertInst;
        notIncludeDeepOrderedMembers<T>(
            superset: ArrayLikeOrSizedIterable<T>,
            subset: ArrayLikeOrSizedIterable<T>,
            initMsg?: MsgSource,
        ): AssertInst;
        notIncludeMembers<T>(
            superset: ArrayLikeOrSizedIterable<T>,
            subset: ArrayLikeOrSizedIterable<T>,
            initMsg?: MsgSource,
        ): AssertInst;
        notIncludeOrderedMembers<T>(
            superset: ArrayLikeOrSizedIterable<T>,
            subset: ArrayLikeOrSizedIterable<T>,
            initMsg?: MsgSource,
        ): AssertInst;
        notIncreasesBy(
            fn: () => void,
            getter: () => any,
            delta: number,
            initMsg?: MsgSource,
        ): AssertInst;
        notIncreasesBy<T>(
            fn: () => void,
            target: T,
            prop: keyof T,
            delta: number,
            initMsg?: MsgSource,
        ): AssertInst;
        notLengthOf<T extends { length?: number } | { size?: number }>(
            object: T,
            length: number,
            initMsg?: MsgSource,
        ): AssertInst;
        notMatch<T>(value: T, regexp: RegExp, initMsg?: MsgSource): AssertInst;
        notNestedInclude<T>(
            value: T,
            expected: any,
            initMsg?: MsgSource,
        ): AssertInst;
        notNestedProperty<T>(
            target: T,
            path: string,
            value?: any,
            initMsg?: MsgSource,
        ): AssertInst;
        notOneOf(
            value: any,
            list: ArrayLikeOrSizedIterable,
            initMsg?: MsgSource,
        ): AssertInst;
        notOwnInclude<T>(value: T, expected: any, initMsg?: MsgSource): AssertInst;
        notSameDeepMembers<T>(
            actual: ArrayLikeOrSizedIterable<T>,
            expected: ArrayLikeOrSizedIterable<T>,
            initMsg?: MsgSource,
        ): AssertInst;
        notSameDeepOrderedMembers<T>(
            actual: ArrayLikeOrSizedIterable<T>,
            expected: ArrayLikeOrSizedIterable<T>,
            initMsg?: MsgSource,
        ): AssertInst;
        notSameMembers<T>(
            actual: ArrayLikeOrSizedIterable<T>,
            expected: ArrayLikeOrSizedIterable<T>,
            initMsg?: MsgSource,
        ): AssertInst;
        notSameOrderedMembers<T>(
            actual: ArrayLikeOrSizedIterable<T>,
            expected: ArrayLikeOrSizedIterable<T>,
            initMsg?: MsgSource,
        ): AssertInst;
        notSizeOf<T extends { length?: number } | { size?: number }>(
            object: T,
            length: number,
            initMsg?: MsgSource,
        ): AssertInst;
        notStartsWithDeepMembers<T>(
            actual: ArrayLikeOrSizedIterable<T>,
            expected: ArrayLikeOrSizedIterable<T>,
            initMsg?: MsgSource,
        ): AssertInst;
        notStartsWithMembers<T>(
            actual: ArrayLikeOrSizedIterable<T>,
            expected: ArrayLikeOrSizedIterable<T>,
            initMsg?: MsgSource,
        ): AssertInst;
        notStrictEqual<T>(
            actual: T,
            expected: unknown,
            initMsg?: MsgSource,
        ): AssertInst;
        notSubsequence<T>(
            actual: ArrayLikeOrSizedIterable<T>,
            expected: ArrayLikeOrSizedIterable<T>,
            initMsg?: MsgSource,
        ): AssertInst;
        notTypeOf(value: any, type: string, initMsg?: MsgSource): AssertInst;
        ok<T>(value: T, initMsg?: MsgSource): AssertInst;
        oneOf(
            value: any,
            list: ArrayLikeOrSizedIterable,
            initMsg?: MsgSource,
        ): AssertInst;
        operator(
            value: any,
            operator: string,
            expected: any,
            initMsg?: MsgSource,
        ): AssertInst;
        ownInclude<T>(value: T, expected: any, initMsg?: MsgSource): AssertInst;
        sameDeepMembers<T>(
            actual: ArrayLikeOrSizedIterable<T>,
            expected: ArrayLikeOrSizedIterable<T>,
            initMsg?: MsgSource,
        ): AssertInst;
        sameDeepOrderedMembers<T>(
            actual: ArrayLikeOrSizedIterable<T>,
            expected: ArrayLikeOrSizedIterable<T>,
            initMsg?: MsgSource,
        ): AssertInst;
        sameMembers<T>(
            actual: ArrayLikeOrSizedIterable<T>,
            expected: ArrayLikeOrSizedIterable<T>,
            initMsg?: MsgSource,
        ): AssertInst;
        sameOrderedMembers<T>(
            actual: ArrayLikeOrSizedIterable<T>,
            expected: ArrayLikeOrSizedIterable<T>,
            initMsg?: MsgSource,
        ): AssertInst;
        sizeOf<T extends { length?: number } | { size?: number }>(
            object: T,
            length: number,
            initMsg?: MsgSource,
        ): AssertInst;
        startsWithDeepMembers<T>(
            actual: ArrayLikeOrSizedIterable<T>,
            expected: ArrayLikeOrSizedIterable<T>,
            initMsg?: MsgSource,
        ): AssertInst;
        startsWithMembers<T>(
            actual: ArrayLikeOrSizedIterable<T>,
            expected: ArrayLikeOrSizedIterable<T>,
            initMsg?: MsgSource,
        ): AssertInst;
        strictEqual<T>(
            actual: T,
            expected: unknown,
            initMsg?: MsgSource,
        ): AssertInst;
        strictEquals<T>(
            actual: T,
            expected: unknown,
            initMsg?: MsgSource,
        ): AssertInst;
        subsequence<T>(
            actual: ArrayLikeOrSizedIterable<T>,
            expected: ArrayLikeOrSizedIterable<T>,
            initMsg?: MsgSource,
        ): AssertInst;
        throws(
            fn: () => void,
            errorLike?: Error | ErrorConstructor,
            msgMatch?: string | RegExp,
            initMsg?: MsgSource,
        ): AssertInst;
        throws(
            fn: () => void,
            msgMatch?: string | RegExp,
            initMsg?: MsgSource,
        ): AssertInst;
        typeOf(value: any, type: string, initMsg?: MsgSource): AssertInst;
        (expr: any, initMsg?: MsgSource): AssertInst;
        (actual: any, expected: any, failMsg?: MsgSource, operator?: string): never;
    }

    Type Parameters

    • Throws an AssertionFailure with the given message if expr is falsy. This method is used to assert that an expression evaluates to a truthy value.

      Parameters

      • expr: any

        The expression to evaluate. If the expression is falsy, an AssertionFailure is thrown.

      • OptionalinitMsg: MsgSource

        The message to display if expr is falsy. This can be a string or a function returning a string.

      Returns AssertInst

      That the expr is truthy and throws AssertionFailure if it is not.

      assert(true); // Passes
      assert(1); // Passes
      assert("a"); // Passes
      assert([]); // Passes
      assert({}); // Passes
      assert(new Map()); // Passes
      assert(new Set()); // Passes
      assert(new Date()); // Passes
      assert(false); // Throws AssertionFailure
      assert(0); // Throws AssertionFailure
      assert(""); // Throws AssertionFailure
      assert(null); // Throws AssertionFailure
      assert(undefined); // Throws AssertionFailure
    • Throws an AssertionFailure exception with then given message and includes the actual and expected and operator in the properties of the exception. This bypases the normal evaluation and will ALWAYS throw an exception, it does not perform any evaluation.

      Parameters

      • actual: any

        The actual value

      • expected: any

        The expected value

      • OptionalfailMsg: MsgSource

        The optional message to include in the exception for the failure.

      • Optionaloperator: string

        The operator used in the evaluation

      Returns never

    Index

    Properties

    Methods

    approximately changes changesButNotBy changesBy closeTo decreases decreasesButNotBy decreasesBy deepEqual deepEquals deepNestedInclude deepNestedProperty deepOwnInclude deepStrictEqual deepStrictEquals deepSubsequence doesNotChange doesNotDecrease doesNotHaveAllDeepKeys doesNotHaveAllKeys doesNotHaveAnyDeepKeys doesNotHaveAnyKeys doesNotIncrease doesNotThrow endsWithDeepMembers endsWithMembers equal equals exists fail fatal hasAllDeepKeys hasAllKeys hasAnyDeepKeys hasAnyKeys hasDeepOwnProperty hasDeepProperty hasOwnProperty hasProperty ifError includeDeepMembers includeDeepOrderedMembers includeMembers includeOrderedMembers includes increases increasesButNotBy increasesBy isAbove isArray isAtLeast isAtMost isBelow isBoolean isEmpty isError isExtensible isFalse isFinite isFrozen isFunction isInstanceOf isIterable isNaN isNotAbove isNotArray isNotAtLeast isNotAtMost isNotBelow isNotBoolean isNotEmpty isNotExtensible isNotFalse isNotFinite isNotFrozen isNotFunction isNotInstanceOf isNotIterable isNotNaN isNotNull isNotNumber isNotObject isNotOk isNotPlainObject isNotSealed isNotString isNotTrue isNotUndefined isNotWithin isNull isNumber isObject isOk isPlainObject isSealed isString isTrue isUndefined isWithin lengthOf match nestedInclude nestedProperty notApproximately notChangesBy notCloseTo notDecreasesBy notDeepEqual notDeepEquals notDeepNestedInclude notDeepNestedProperty notDeepOwnInclude notDeepSubsequence notEndsWithDeepMembers notEndsWithMembers notEqual notEquals notExists notHasDeepOwnProperty notHasDeepProperty notHasOwnProperty notHasProperty notHaveAllDeepKeys notHaveAnyDeepKeys notIncludeDeepMembers notIncludeDeepOrderedMembers notIncludeMembers notIncludeOrderedMembers notIncreasesBy notLengthOf notMatch notNestedInclude notNestedProperty notOneOf notOwnInclude notSameDeepMembers notSameDeepOrderedMembers notSameMembers notSameOrderedMembers notSizeOf notStartsWithDeepMembers notStartsWithMembers notStrictEqual notSubsequence notTypeOf ok oneOf operator ownInclude sameDeepMembers sameDeepOrderedMembers sameMembers sameOrderedMembers sizeOf startsWithDeepMembers startsWithMembers strictEqual strictEquals subsequence throws typeOf

    Properties

    _$lastContext: IScopeContext

    Returns the last executed IScopeContext of the assertion chain of the immediately preceeding assertion operation. Does not support asynchronous operations as it is always overwritten by the last evaluated scope, used primarily to provide additional context for the error message during unexpected "pass" conditions.

    Methods

    • Alias for closeTo. Asserts that the actual value is approximately equal to the expected value within the specified delta.

      Parameters

      • actual: number

        The actual value to check. Must be a number.

      • expected: number

        The expected value to compare against. Must be a number.

      • delta: number

        The maximum allowed difference between actual and expected. Must be a number. Note: A negative delta will never result in a passing assertion since the absolute difference is always non-negative.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      closeTo

      0.1.5

      assert.approximately(1.5, 1.0, 0.5);  // Passes - difference is 0.5
      assert.approximately(10, 20, 20); // Passes - difference is 10
      assert.approximately(2, 1.0, 0.5); // Throws AssertionFailure - difference is 1.0
    • Asserts that executing the target function changes the monitored value. Can monitor either a getter function's return value or an object property.

      Parameters

      • fn: () => void

        The function to execute that should change the value.

      • getter: () => any

        A function that returns the value to monitor.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      let value = 1;
      const getValue = () => value;
      const changeValue = () => { value = 2; };
      assert.changes(changeValue, getValue);

      const obj = { count: 0 };
      const increment = () => { obj.count++; };
      assert.changes(increment, obj, 'count');
    • Asserts that executing the target function changes the monitored value. Can monitor either a getter function's return value or an object property.

      Type Parameters

      • T = any

      Parameters

      • fn: () => void

        The function to execute that should change the value.

      • target: T

        An object containing the property.

      • prop: keyof T

        The property name to monitor (only when getter is an object).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      let value = 1;
      const getValue = () => value;
      const changeValue = () => { value = 2; };
      assert.changes(changeValue, getValue);

      const obj = { count: 0 };
      const increment = () => { obj.count++; };
      assert.changes(increment, obj, 'count');
    • Asserts that the value DOES change but NOT by the specified delta after executing the target function. The value MUST change (cannot remain the same), but the change amount must not equal the specified delta. This differs from notChangesBy which allows the value to remain unchanged.

      Parameters

      • fn: () => void

        The function to execute that should change the value.

      • getter: () => any

        A function that returns the value to monitor.

      • delta: number

        The delta that should NOT match (sign is considered).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      let value = 0;
      const getValue = () => value;
      const addTwo = () => { value += 2; };
      const noOp = () => {};
      assert.changesButNotBy(addTwo, getValue, 5); // Passes - changed by 2, not by 5
      assert.changesButNotBy(addTwo, getValue, 2); // Fails - changed by exactly 2
      assert.changesButNotBy(noOp, getValue, 5); // Fails - no change occurred
    • Asserts that the property DOES change but NOT by the specified delta after executing the target function. The value MUST change (cannot remain the same), but the change amount must not equal the specified delta. This differs from notChangesBy which allows the value to remain unchanged.

      Type Parameters

      • T

      Parameters

      • fn: () => void

        The function to execute that should change the value.

      • target: T

        An object containing the property to monitor.

      • prop: keyof T

        The property name to monitor.

      • delta: number

        The delta that should NOT match (sign is considered).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      const obj = { count: 10 };
      const addTwo = () => { obj.count += 2; };
      const noOp = () => {};
      assert.changesButNotBy(addTwo, obj, 'count', 5); // Passes - changed by 2, not by 5
      assert.changesButNotBy(addTwo, obj, 'count', 2); // Fails - changed by exactly 2
      assert.changesButNotBy(noOp, obj, 'count', 5); // Fails - no change occurred
    • Asserts that executing the target function changes the monitored value by the specified delta. Important: The sign of the delta is ignored - only the absolute value is compared. This means both positive and negative deltas with the same absolute value will match.

      Parameters

      • fn: () => void

        The function to execute that should change the value.

      • getter: () => any

        A function that returns the value to monitor.

      • delta: number

        The expected delta (sign is ignored, only absolute value matters).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      let value = 0;
      const getValue = () => value;
      const addFive = () => { value += 5; };
      const subtractFive = () => { value -= 5; };
      assert.changesBy(addFive, getValue, 5); // Passes (delta of +5)
      assert.changesBy(addFive, getValue, -5); // Also passes (absolute value is 5)
      assert.changesBy(subtractFive, getValue, 5); // Also passes (absolute value is 5)
    • Asserts that executing the target function changes the monitored object property by the specified delta. Important: The sign of the delta is ignored - only the absolute value is compared. This means both positive and negative deltas with the same absolute value will match.

      Type Parameters

      • T

      Parameters

      • fn: () => void

        The function to execute that should change the value.

      • target: T

        An object containing the property to monitor.

      • prop: keyof T

        The property name to monitor.

      • delta: number

        The expected delta (sign is ignored, only absolute value matters).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      const obj = { count: 10 };
      const addFive = () => { obj.count += 5; };
      const subtractFive = () => { obj.count -= 5; };
      assert.changesBy(addFive, obj, 'count', 5); // Passes (delta of +5)
      assert.changesBy(addFive, obj, 'count', -5); // Also passes (absolute value is 5)
      assert.changesBy(subtractFive, obj, 'count', 5); // Also passes (absolute value is 5)
    • Asserts that the actual value is close to the expected value within the specified delta. This is useful for floating-point comparisons where exact equality is not guaranteed. The absolute difference between the actual and expected values must be less than or equal to delta.

      Parameters

      • actual: number

        The actual value to check. Must be a number.

      • expected: number

        The expected value to compare against. Must be a number.

      • delta: number

        The maximum allowed difference between actual and expected. Must be a number. Note: A negative delta will never result in a passing assertion since the absolute difference is always non-negative.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      assert.closeTo(1.5, 1.0, 0.5);  // Passes - difference is 0.5
      assert.closeTo(10, 20, 20); // Passes - difference is 10
      assert.closeTo(-10, 20, 30); // Passes - difference is 30
      assert.closeTo(2, 1.0, 0.5); // Throws AssertionFailure - difference is 1.0
      assert.closeTo(-10, 20, 29); // Throws AssertionFailure - difference is 30
    • Asserts that executing the target function decreases the monitored numeric value.

      Parameters

      • fn: () => void

        The function to execute that should decrease the value.

      • getter: () => any

        A function that returns the value to monitor.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      let count = 10;
      const getCount = () => count;
      const decrement = () => { count--; };
      assert.decreases(decrement, getCount);
    • Asserts that executing the target function decreases the monitored object property.

      Type Parameters

      • T

      Parameters

      • fn: () => void

        The function to execute that should decrease the value.

      • target: T

        An object containing the property to monitor.

      • prop: keyof T

        The property name to monitor.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      const obj = { count: 10 };
      const subtractThree = () => { obj.count -= 3; };
      assert.decreases(subtractThree, obj, 'count');
    • Asserts that executing the target function decreases the monitored value but NOT by the specified delta. The value MUST decrease, but the decrease amount must not equal the specified delta.

      Parameters

      • fn: () => void

        The function to execute that should decrease the value.

      • getter: () => any

        A function that returns the value to monitor.

      • delta: number

        The delta that should NOT match.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      let value = 10;
      const getValue = () => value;
      const subtractTwo = () => { value -= 2; };
      assert.decreasesButNotBy(subtractTwo, getValue, 5); // Passes - decreased by 2, not 5
      assert.decreasesButNotBy(subtractTwo, getValue, 2); // Fails - decreased by exactly 2
    • Asserts that executing the target function decreases the monitored object property but NOT by the specified delta. The value MUST decrease, but the decrease amount must not equal the specified delta.

      Type Parameters

      • T

      Parameters

      • fn: () => void

        The function to execute that should decrease the value.

      • target: T

        An object containing the property to monitor.

      • prop: keyof T

        The property name to monitor.

      • delta: number

        The delta that should NOT match.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      const obj = { count: 10 };
      const subtractTwo = () => { obj.count -= 2; };
      assert.decreasesButNotBy(subtractTwo, obj, 'count', 5); // Passes - decreased by 2, not 5
      assert.decreasesButNotBy(subtractTwo, obj, 'count', 2); // Fails - decreased by exactly 2
    • Asserts that executing the target function decreases the monitored value by the specified delta.

      Parameters

      • fn: () => void

        The function to execute that should decrease the value.

      • getter: () => any

        A function that returns the value to monitor.

      • delta: number

        The expected decrease delta (should be a positive value as a decrease is expected).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      let value = 10;
      const getValue = () => value;
      const subtractFive = () => { value -= 5; };
      assert.decreasesBy(subtractFive, getValue, 5);
    • Asserts that executing the target function decreases the monitored object property by the specified delta.

      Type Parameters

      • T

      Parameters

      • fn: () => void

        The function to execute that should decrease the value.

      • target: T

        An object containing the property to monitor.

      • prop: keyof T

        The property name to monitor.

      • delta: number

        The expected decrease delta (should be a positive value as a decrease is expected).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      const obj = { count: 10 };
      const subtractFive = () => { obj.count -= 5; };
      assert.decreasesBy(subtractFive, obj, 'count', 5);
    • Performs a deep equality check between the actual and expected values, throwing an AssertionFailure with the given message when the actual value is not deeply equal to the expected value. This method compares the values of all properties of objects and elements of arrays.

      Type Parameters

      • T

        The type of the values.

      Parameters

      • actual: T

        The actual value.

      • expected: unknown

        The expected value.

      • OptionalinitMsg: MsgSource

        The message to display if actual is not deeply equal to expected.

      Returns AssertInst

      That the actual and expected values are deeply equal and throws AssertionFailure if they are not.

      assert.deepEqual({ a: 1 }, { a: 1 }); // Passes
      assert.deepEqual({ a: 1 }, { a: 2 }); // Throws AssertionFailure
      assert.deepEqual([1, 2], [1, 2]); // Passes
      assert.deepEqual([1, 2], [2, 1]); // Throws AssertionFailure
      assert.deepEqual({ a: { b: 1 } }, { a: { b: 1 } }); // Passes
      assert.deepEqual({ a: { b: 1 } }, { a: { b: 2 } }); // Throws AssertionFailure
      assert.deepEqual([{ a: 1 }], [{ a: 1 }]); // Passes
      assert.deepEqual([{ a: 1 }], [{ a: 2 }]); // Throws AssertionFailure
    • Performs a deep equality check between the actual and expected values, throwing an AssertionFailure with the given message when the actual value is not deeply equal to the expected value. This method compares the values of all properties of objects and elements of arrays.

      Type Parameters

      • T

        The type of the values.

      Parameters

      • actual: T

        The actual value.

      • expected: unknown

        The expected value.

      • OptionalinitMsg: MsgSource

        The message to display if actual is not deeply equal to expected.

      Returns AssertInst

      That the actual and expected values are deeply equal and throws AssertionFailure if they are not.

      deepEqual

      assert.deepEquals({ a: 1 }, { a: 1 }); // Passes
      assert.deepEquals({ a: 1 }, { a: 2 }); // Throws AssertionFailure
      assert.deepEquals([1, 2], [1, 2]); // Passes
      assert.deepEquals([1, 2], [2, 1]); // Throws AssertionFailure
      assert.deepEquals({ a: { b: 1 } }, { a: { b: 1 } }); // Passes
      assert.deepEquals({ a: { b: 1 } }, { a: { b: 2 } }); // Throws AssertionFailure
      assert.deepEquals([{ a: 1 }], [{ a: 1 }]); // Passes
      assert.deepEquals([{ a: 1 }], [{ a: 2 }]); // Throws AssertionFailure
    • Asserts that the value contains the expected using deep nested property matching. Each property in the expected is deeply compared against the value.

      Type Parameters

      • T

      Parameters

      • value: T

        The object to search in.

      • expected: any

        The object with properties to match (can use dot notation for keys).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value contains the match using deep nested property matching and throws AssertionFailure if it does not.

      0.1.5

      assert.deepNestedInclude({ a: { b: { c: { d: 1 } } } }, { 'a.b.c': { d: 1 } }); // Passes
      assert.deepNestedInclude({ a: { b: { c: [1, 2, 3] } } }, { 'a.b.c': [1, 2, 3] }); // Passes
      assert.deepNestedInclude({ a: { b: { c: { d: 1 } } } }, { 'a.b.c': { d: 2 } }); // Throws AssertionFailure
    • Asserts that the provided value has the specified nested property with a value that matches using deep equality.

      Type Parameters

      • T

      Parameters

      • target: T

        The value to evaluate.

      • path: string

        The dot-separated path to the property (e.g., "a.b.c").

      • Optionalvalue: any

        Optional. The expected value of the property (uses deep equality).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value has the specified nested property with matching deep value and throws AssertionFailure if it does not.

      0.1.5

      assert.deepNestedProperty({ a: { b: { c: { d: 1 } } } }, "a.b.c"); // Passes
      assert.deepNestedProperty({ a: { b: { c: { d: 1 } } } }, "a.b.c", { d: 1 }); // Passes
      assert.deepNestedProperty({ a: { b: { c: [1, 2, 3] } } }, "a.b.c", [1, 2, 3]); // Passes
      assert.deepNestedProperty({ a: { b: { c: { d: 1 } } } }, "a.b.c", { d: 2 }); // Throws AssertionFailure
    • Asserts that the value contains the expected using deep own property matching. For objects, checks that all keys in the expected are own properties (not inherited) and that values match using deep equality.

      Type Parameters

      • T

      Parameters

      • value: T

        The object to search in.

      • expected: any

        The value or object with properties to match.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value deeply contains the expected using own property matching and throws AssertionFailure if it does not.

      0.1.5

      assert.deepOwnInclude({ a: { b: 1 } }, { a: { b: 1 } }); // Passes
      assert.deepOwnInclude({ a: [1, 2, 3] }, { a: [1, 2, 3] }); // Passes
      assert.deepOwnInclude({ a: { b: 1 } }, { a: { b: 2 } }); // Throws AssertionFailure
      // Inherited properties are not matched:
      const obj = Object.create({ inherited: { deep: 1 } });
      obj.own = { deep: 2 };
      assert.deepOwnInclude(obj, { own: { deep: 2 } }); // Passes
      assert.deepOwnInclude(obj, { inherited: { deep: 1 } }); // Throws AssertionFailure
    • Performs a deep strict equality check between the actual and expected values, throwing an AssertionFailure with the given message when the actual value is not deeply strictly equal to the expected value. This method compares the values of all properties of objects and elements of arrays, ensuring that both the values and their types are equal.

      Type Parameters

      • T

        The type of the values.

      Parameters

      • actual: T

        The actual value.

      • expected: unknown

        The expected value.

      • OptionalinitMsg: MsgSource

        The message to display if actual is not deeply strictly equal to expected.

      Returns AssertInst

      That the actual and expected values are deeply and strictly equal and throws AssertionFailure if they are not.

      assert.deepStrictEqual({ a: 1 }, { a: 1 }); // Passes
      assert.deepStrictEqual({ a: 1 }, { a: "1" }); // Throws AssertionFailure
      assert.deepStrictEqual([1, 2], [1, 2]); // Passes
      assert.deepStrictEqual([1, 2], [2, 1]); // Throws AssertionFailure
      assert.deepStrictEqual({ a: { b: 1 } }, { a: { b: 1 } }); // Passes
      assert.deepStrictEqual({ a: { b: 1 } }, { a: { b: "1" } }); // Throws AssertionFailure
      assert.deepStrictEqual([{ a: 1 }], [{ a: 1 }]); // Passes
      assert.deepStrictEqual([{ a: 1 }], [{ a: "1" }]); // Throws AssertionFailure
    • Performs a deep strict equality check between the actual and expected values, throwing an AssertionFailure with the given message when the actual value is not deeply strictly equal to the expected value. This method compares the values of all properties of objects and elements of arrays, ensuring that both the values and their types are equal.

      Type Parameters

      • T

        The type of the values.

      Parameters

      • actual: T

        The actual value.

      • expected: unknown

        The expected value.

      • OptionalinitMsg: MsgSource

        The message to display if actual is not deeply strictly equal to expected.

      Returns AssertInst

      That the actual and expected values are deeply and strictly equal and throws AssertionFailure if they are not.

      assert.deepStrictEquals({ a: 1 }, { a: 1 }); // Passes
      assert.deepStrictEquals({ a: 1 }, { a: "1" }); // Throws AssertionFailure
      assert.deepStrictEquals([1, 2], [1, 2]); // Passes
      assert.deepStrictEquals([1, 2], [2, 1]); // Throws AssertionFailure
      assert.deepStrictEquals({ a: { b: 1 } }, { a: { b: 1 } }); // Passes
      assert.deepStrictEquals({ a: { b: 1 } }, { a: { b: "1" } }); // Throws AssertionFailure
      assert.deepStrictEquals([{ a: 1 }], [{ a: 1 }]); // Passes
      assert.deepStrictEquals([{ a: 1 }], [{ a: "1" }]); // Throws AssertionFailure
    • Asserts that executing the target function does NOT change the monitored value. This is the inverse of changes.

      Parameters

      • fn: () => void

        The function to execute.

      • getter: () => any

        A function that returns the value to monitor.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      let value = 1;
      const getValue = () => value;
      const noOp = () => {};
      assert.doesNotChange(noOp, getValue);
    • Asserts that executing the target function does NOT change the monitored object property. This is the inverse of changes.

      Type Parameters

      • T

      Parameters

      • fn: () => void

        The function to execute.

      • target: T

        An object containing the property to monitor.

      • prop: keyof T

        The property name to monitor.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      const obj = { count: 0 };
      const noOp = () => {};
      assert.doesNotChange(noOp, obj, 'count');
    • Asserts that executing the target function does NOT decrease the monitored numeric value. This is the inverse of decreases.

      Parameters

      • fn: () => void

        The function to execute.

      • getter: () => any

        A function that returns the value to monitor.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      let value = 5;
      const getValue = () => value;
      const noOp = () => {};
      assert.doesNotDecrease(noOp, getValue);
    • Asserts that executing the target function does NOT decrease the monitored object property. This is the inverse of decreases.

      Type Parameters

      • T

      Parameters

      • fn: () => void

        The function to execute.

      • target: T

        An object containing the property to monitor.

      • prop: keyof T

        The property name to monitor.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      const obj = { count: 5 };
      const noOp = () => {};
      assert.doesNotDecrease(noOp, obj, 'count');
    • Asserts that the target does NOT have all of the specified keys using deep equality comparison. This method checks that at least one of the given keys does not exist in the target using deep equality for key comparison. This is the inverse of hasAllDeepKeys.

      Parameters

      • target: any

        The object, Map, or Set to check for keys.

      • keys: any

        The keys to search for (array, Set, Map, or other iterable of keys, or a single key).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the target does not have all of the specified keys and throws AssertionFailure if it does.

      notHaveAllDeepKeys

      0.1.5

      const obj = { greeting: "hello", subject: "friend" };
      assert.doesNotHaveAllDeepKeys(obj, "unknown"); // Passes - missing "unknown"
      assert.doesNotHaveAllDeepKeys(obj, ["greeting", "unknown"]); // Passes - missing "unknown"

      const map = new Map([[{ id: 1 }, "value1"]]);
      assert.doesNotHaveAllDeepKeys(map, [{ id: 1 }, { id: 2 }]); // Passes - missing { id: 2 }
      assert.doesNotHaveAllDeepKeys(obj, ["greeting", "subject"]); // Throws AssertionFailure - has both keys
    • Asserts that the target does NOT have all of the specified keys. This method checks that at least one of the given keys does not exist in the target. This is the inverse of hasAllKeys.

      Parameters

      • target: any

        The object, Map, or Set to check for keys.

      • keys: any

        The keys to search for (array, Set, Map, or other iterable of keys, or a single key).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the target does not have all of the specified keys and throws AssertionFailure if it does.

      0.1.5

      const obj = { greeting: "hello", subject: "friend" };
      assert.doesNotHaveAllKeys(obj, "unknown"); // Passes - missing "unknown"
      assert.doesNotHaveAllKeys(obj, ["greeting", "unknown"]); // Passes - missing "unknown"
      assert.doesNotHaveAllKeys(obj, ["greeting", "subject"]); // Throws AssertionFailure - has both keys

      const map = new Map([["a", 1], ["b", 2]]);
      assert.doesNotHaveAllKeys(map, ["a", "c"]); // Passes - missing "c"
    • Asserts that the target does NOT have any of the specified keys using deep equality comparison. This method checks that none of the given keys exist in the target using deep equality for key comparison. This is the inverse of hasAnyDeepKeys.

      Parameters

      • target: any

        The object, Map, or Set to check for keys.

      • keys: any

        The keys to search for (array, Set, Map, or other iterable of keys, or a single key).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the target does not have any of the specified keys and throws AssertionFailure if it does.

      notHaveAnyDeepKeys

      0.1.5

      const obj = { greeting: "hello", subject: "friend" };
      assert.doesNotHaveAnyDeepKeys(obj, "unknown"); // Passes - does not have the key
      assert.doesNotHaveAnyDeepKeys(obj, ["unknown", "missing"]); // Passes - has neither key

      const map = new Map([[{ id: 1 }, "value1"]]);
      assert.doesNotHaveAnyDeepKeys(map, [{ id: 3 }, { id: 4 }]); // Passes - has neither key
      assert.doesNotHaveAnyDeepKeys(obj, ["greeting", "unknown"]); // Throws AssertionFailure - has "greeting"
    • Asserts that the target does NOT have any of the specified keys. This method checks that none of the given keys exist in the target. This is the inverse of hasAnyKeys.

      Parameters

      • target: any

        The object, Map, or Set to check for keys.

      • keys: any

        The keys to search for (array, Set, Map, or other iterable of keys, or a single key).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the target does not have any of the specified keys and throws AssertionFailure if it does.

      0.1.5

      const obj = { greeting: "hello", subject: "friend" };
      assert.doesNotHaveAnyKeys(obj, "unknown"); // Passes - does not have the key
      assert.doesNotHaveAnyKeys(obj, ["unknown", "missing"]); // Passes - has neither key
      assert.doesNotHaveAnyKeys(obj, ["greeting", "unknown"]); // Throws AssertionFailure - has "greeting"

      const map = new Map([["a", 1], ["b", 2]]);
      assert.doesNotHaveAnyKeys(map, ["c", "d"]); // Passes - has neither key
    • Asserts that executing the target function does NOT increase the monitored numeric value. This is the inverse of increases.

      Parameters

      • fn: () => void

        The function to execute.

      • getter: () => any

        A function that returns the value to monitor.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      let value = 5;
      const getValue = () => value;
      const noOp = () => {};
      assert.doesNotIncrease(noOp, getValue);
    • Asserts that executing the target function does NOT increase the monitored object property. This is the inverse of increases.

      Type Parameters

      • T

      Parameters

      • fn: () => void

        The function to execute.

      • target: T

        An object containing the property to monitor.

      • prop: keyof T

        The property name to monitor.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      const obj = { count: 5 };
      const noOp = () => {};
      assert.doesNotIncrease(noOp, obj, 'count');
    • Asserts that the given function does NOT throw an error. Optionally checks that if an error is thrown, it does not match the specified error constructor or message pattern. If the function throws an error (that matches the optional criteria), it throws an AssertionFailure with the given message. This is the inverse of throws.

      Parameters

      • fn: () => void

        The function to execute and check for thrown errors.

      • OptionalerrorLike: Error | ErrorConstructor

        Optional. The error constructor or error instance that should NOT be thrown.

      • OptionalmsgMatch: string | RegExp

        Optional. The partial message or pattern that should NOT match.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the function does not throw an error (or does not throw a matching error) and throws AssertionFailure if it does.

      0.1.5

      assert.doesNotThrow(() => {}); // Passes - no error thrown
      assert.doesNotThrow(() => { return 42; }); // Passes - no error thrown
      assert.doesNotThrow(() => { throw new Error("test"); }); // Throws AssertionFailure
      assert.doesNotThrow(() => { throw new TypeError("test"); }); // Throws AssertionFailure
    • Asserts that the given function does NOT throw an error with a message matching the pattern. If the function throws an error with a matching message, it throws an AssertionFailure with the given message. This is the inverse of throws.

      Parameters

      • fn: () => void

        The function to execute and check for thrown errors.

      • OptionalmsgMatch: string | RegExp

        Optional. The partial message or pattern that should NOT match.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the function does not throw an error with a matching message and throws AssertionFailure if it does.

      0.1.5

      assert.doesNotThrow(() => {}, /test/); // Passes - no error thrown
      assert.doesNotThrow(() => { throw new Error("other"); }, /test/); // Passes - message doesn't match
      assert.doesNotThrow(() => { throw new Error("test"); }, /test/); // Throws AssertionFailure
    • Performs a loose 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. To perform a strict equality check (===), use the assert.strictEqual method.

      Type Parameters

      • T

        The type of the values.

      Parameters

      • actual: T

        The actual value.

      • expected: unknown

        The expected value.

      • OptionalinitMsg: MsgSource

        The message to display if actual is not equal to expected.

      Returns AssertInst

      That the actual and expected values are loosely (==) equal and throws AssertionFailure if they are not.

      assert.equal(1, 1); // Passes
      assert.equal(1, "1"); // Passes
      assert.equal(1, 2); // Throws AssertionFailure
      assert.equal("a", "a"); // Passes
      assert.equal("a", "b"); // Throws AssertionFailure
      assert.equal([1, 2], [1, 2]); // Throws AssertionFailure
      assert.equal({ a: 1 }, { a: 1 }); // Throws AssertionFailure
      assert.equal({ a: 1 }, { a: 1 }, "Objects are not equal"); // Throws AssertionFailure
      assert.equal({ a: 1 }, { a: 2 }); // Throws AssertionFailure
      assert.equal({ a: 1 }, { a: 2 }, "Objects are not equal"); // Throws AssertionFailure
      assert.equal({ a: 1 }, { b: 1 }); // Throws AssertionFailure
      assert.equal({ a: 1 }, { b: 1 }, "Objects are not equal"); // Throws AssertionFailure
      assert.equal({ a: 1 }, { b: 2 }); // Throws AssertionFailure
      assert.equal({ a: 1 }, { b: 2 }, "Objects are not equal"); // Throws AssertionFailure
    • Performs a loose 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. To perform a strict equality check (===), use the assert.strictEqual method.

      Type Parameters

      • T

        The type of the value.

      Parameters

      • actual: T

        The actual value.

      • expected: unknown

        The expected value.

      • OptionalinitMsg: MsgSource

        The message to display if actual is not equal to expected.

      Returns AssertInst

      That the actual and expected values are loosely (==) equal and throws AssertionFailure if they are not.

      equal

      assert.equals(1, 1); // Passes
      assert.equals(1, "1"); // Passes
      assert.equals(1, 2); // Throws AssertionFailure
      assert.equals("a", "a"); // Passes
      assert.equals("a", "b"); // Throws AssertionFailure
      assert.equals([1, 2], [1, 2]); // Throws AssertionFailure
      assert.equals({ a: 1 }, { a: 1 }); // Throws AssertionFailure
      assert.equals({ a: 1 }, { a: 1 }, "Objects are not equal"); // Throws AssertionFailure
      assert.equals({ a: 1 }, { a: 2 }); // Throws AssertionFailure
      assert.equals({ a: 1 }, { a: 2 }, "Objects are not equal"); // Throws AssertionFailure
      assert.equals({ a: 1 }, { b: 1 }); // Throws AssertionFailure
      assert.equals({ a: 1 }, { b: 1 }, "Objects are not equal"); // Throws AssertionFailure
      assert.equals({ a: 1 }, { b: 2 }); // Throws AssertionFailure
      assert.equals({ a: 1 }, { b: 2 }, "Objects are not equal"); // Throws AssertionFailure
    • Asserts that the given value exists (is not null and not undefined).

      Parameters

      • value: any

        The value to check.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      0.1.5

      That the value is not null and not undefined and throws AssertionFailure if it is.

      assert.exists(0); // Passes - 0 is not null or undefined
      assert.exists(""); // Passes - empty string exists
      assert.exists(false); // Passes - false exists
      assert.exists([]); // Passes - arrays exist
      assert.exists({}); // Passes - objects exist
      assert.exists(null); // Throws AssertionFailure
      assert.exists(undefined); // Throws AssertionFailure
    • Throws an AssertionFailure with the given message. This method is used to explicitly fail an assertion with a custom message.

      Parameters

      • OptionalinitMsg: MsgSource

        The message to display. This can be a string or a function returning a string.

      Returns never

      AssertionFailure - Always.

      assert.fail(); // Throws AssertionFailure
      assert.fail("Hello Darkness, my old friend"); // Throws AssertionFailure
      assert.fail(() => "Looks like we have failed again"); // Throws AssertionFailure
    • Throws an AssertionFailure with the given message and optional details which are obtained via the getDetails function.

      Parameters

      • actual: any

        The actual value that was expected

      • expected: any

        The expected value that was not found

      • OptionalfailMsg: MsgSource

        The message to display.

      • Optionaloperator: string

        The optional operator used in the comparison

      Returns never

      AssertionFailure always

      assert.fail(1, 2, "Values are not equal"); // Throws AssertionFailure
      assert.fail(1, 2, "Values are not equal", "=="); // Throws AssertionFailure
    • Throws an AssertionFatal with the given message. This method is used to explicitly fail an assertion with a custom message.

      Parameters

      • OptionalinitMsg: MsgSource

        The message to display. This can be a string or a function returning a string.

      Returns never

      AssertionFatal - Always.

      assert.fatal(); // Throws AssertionFatal
      assert.fatal("Hello Darkness, my old friend"); // Throws AssertionFatal
      assert.fatal(() => "Looks like we have failed again"); // Throws AssertionFatal
    • Asserts that the target has all of the specified keys using deep equality comparison. This method checks if all of the given keys exist in the target using deep equality for key comparison. Particularly useful for Maps and Sets where keys may be objects.

      Parameters

      • target: any

        The object, Map, or Set to check for keys.

      • keys: any

        The keys to search for (array, Set, Map, or other iterable of keys, or a single key).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the target has all of the specified keys and throws AssertionFailure if it does not.

      0.1.5

      const obj = { greeting: "hello", subject: "friend", message: "darkness" };
      assert.hasAllDeepKeys(obj, "greeting"); // Passes - has the key
      assert.hasAllDeepKeys(obj, ["greeting", "subject"]); // Passes - has both keys

      const map = new Map([[{ id: 1 }, "value1"], [{ id: 2 }, "value2"]]);
      assert.hasAllDeepKeys(map, [{ id: 1 }, { id: 2 }]); // Passes - has both keys
      assert.hasAllDeepKeys(obj, ["greeting", "unknown"]); // Throws AssertionFailure - missing "unknown"
    • Asserts that the target has all of the specified keys. This method checks if all of the given keys exist in the target. Works with objects, Maps, and Sets.

      Parameters

      • target: any

        The object, Map, or Set to check for keys.

      • keys: any

        The keys to search for (array, Set, Map, or other iterable of keys, or a single key).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the target has all of the specified keys and throws AssertionFailure if it does not.

      0.1.5

      const obj = { greeting: "hello", subject: "friend", message: "darkness" };
      assert.hasAllKeys(obj, "greeting"); // Passes - has the key
      assert.hasAllKeys(obj, ["greeting", "subject"]); // Passes - has both keys
      assert.hasAllKeys(obj, ["greeting", "unknown"]); // Throws AssertionFailure - missing "unknown"

      const map = new Map([["a", 1], ["b", 2]]);
      assert.hasAllKeys(map, ["a", "b"]); // Passes - has both keys
    • Asserts that the target has any of the specified keys using deep equality comparison. This method checks if at least one of the given keys exists in the target using deep equality for key comparison. Particularly useful for Maps and Sets where keys may be objects.

      Parameters

      • target: any

        The object, Map, or Set to check for keys.

      • keys: any

        The keys to search for (array, Set, Map, or other iterable of keys, or a single key).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the target has at least one of the specified keys and throws AssertionFailure if it does not.

      0.1.5

      const obj = { greeting: "hello", subject: "friend" };
      assert.hasAnyDeepKeys(obj, "greeting"); // Passes - has "greeting"
      assert.hasAnyDeepKeys(obj, ["greeting", "message"]); // Passes - has "greeting"

      const map = new Map([[{ id: 1 }, "value1"], [{ id: 2 }, "value2"]]);
      assert.hasAnyDeepKeys(map, { id: 1 }); // Passes - deep key match
      assert.hasAnyDeepKeys(map, [{ id: 1 }, { id: 3 }]); // Passes - has { id: 1 }
      assert.hasAnyDeepKeys(obj, ["unknown", "missing"]); // Throws AssertionFailure
    • Asserts that the target has any of the specified keys. This method checks if at least one of the given keys exists in the target. Works with objects, Maps, and Sets.

      Parameters

      • target: any

        The object, Map, or Set to check for keys.

      • keys: any

        The keys to search for (array, Set, Map, or other iterable of keys, or a single key).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the target has at least one of the specified keys and throws AssertionFailure if it does not.

      0.1.5

      const obj = { greeting: "hello", subject: "friend" };
      assert.hasAnyKeys(obj, "greeting"); // Passes - has "greeting"
      assert.hasAnyKeys(obj, ["greeting", "message"]); // Passes - has "greeting"
      assert.hasAnyKeys(obj, ["unknown", "missing"]); // Throws AssertionFailure

      const map = new Map([["a", 1], ["b", 2]]);
      assert.hasAnyKeys(map, "a"); // Passes - has "a"
      assert.hasAnyKeys(map, ["a", "c"]); // Passes - has "a"
    • Asserts that the provided value has the specified own property with a value that matches using deep equality. If the value does not have the own property or the deep value doesn't match, it throws an AssertionFailure with the given message.

      Type Parameters

      • T

      Parameters

      • target: T

        The value to evaluate.

      • name: string

        The name of the own property to check for.

      • value: any

        The expected value of the property (uses deep equality).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value has the specified own property with matching deep value and throws AssertionFailure if it does not.

      0.1.5

      assert.hasDeepOwnProperty({ a: { b: 1 } }, "a", { b: 1 }); // Passes
      assert.hasDeepOwnProperty({ arr: [1, 2, 3] }, "arr", [1, 2, 3]); // Passes
      assert.hasDeepOwnProperty(Object.create({ a: 1 }), "a", { b: 1 }); // Throws AssertionFailure
    • Asserts that the provided value has the specified property with a value that matches using deep equality. If the value does not have the property or the deep value doesn't match, it throws an AssertionFailure with the given message.

      Type Parameters

      • T

      Parameters

      • target: T

        The value to evaluate.

      • name: string

        The name of the property to check for.

      • value: any

        The expected value of the property (uses deep equality).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value has the specified property with matching deep value and throws AssertionFailure if it does not.

      0.1.5

      assert.hasDeepProperty({ a: { b: 1 } }, "a", { b: 1 }); // Passes
      assert.hasDeepProperty({ arr: [1, 2, 3] }, "arr", [1, 2, 3]); // Passes
      assert.hasDeepProperty({ a: { b: 1 } }, "a", { b: 2 }); // Throws AssertionFailure
    • Asserts that the provided value has the specified own property (i.e., a property that is not inherited). Optionally checks the property value using loose equality (==). If the value does not have the own property or the value doesn't match, it throws an AssertionFailure with the given message.

      Type Parameters

      • T

      Parameters

      • target: T

        The value to evaluate.

      • name: string

        The name of the own property to check for.

      • Optionalvalue: any

        Optional. The expected value of the property (uses loose equality).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value has the specified own property and throws AssertionFailure if it does not.

      0.1.0 - Property existence check. 0.1.5 - Added optional value parameter.

      assert.hasOwnProperty({ a: 1, b: 2 }, "a"); // Passes
      assert.hasOwnProperty({ a: 1, b: 2 }, "c"); // Throws AssertionFailure
      assert.hasOwnProperty(Object.create({ a: 1 }), "a"); // Throws AssertionFailure
      assert.hasOwnProperty({ a: 1 }, "a", 1); // Passes
      assert.hasOwnProperty({ a: 1 }, "a", 2); // Throws AssertionFailure
    • Asserts that the provided value has the specified property. Optionally checks the property value using loose equality (==). If the value does not have the property or the value doesn't match, it throws an AssertionFailure with the given message.

      Type Parameters

      • T

      Parameters

      • target: T

        The value to evaluate.

      • name: string

        The name of the property to check for.

      • Optionalvalue: any

        Optional. The expected value of the property (uses loose equality).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value has the specified property and throws AssertionFailure if it does not.

      0.1.0 - Property existence check. 0.1.5 - Added optional value parameter.

      assert.hasProperty({ a: 1, b: 2 }, "a"); // Passes
      assert.hasProperty({ a: 1, b: 2 }, "c"); // Throws AssertionFailure
      assert.hasProperty({ a: 1 }, "a", 1); // Passes
      assert.hasProperty({ a: 1 }, "a", "1"); // Passes (loose equality)
      assert.hasProperty({ a: 1 }, "a", 2); // Throws AssertionFailure
    • Asserts that the target is falsy or throws the error if it is an Error instance. This is commonly used in Node.js-style callback error handling to check for errors.

      • If the value is falsy (null, undefined, false, 0, "", etc.), the assertion passes
      • If the value is an Error instance, that error is thrown
      • If the value is truthy but not an Error, an AssertionFailure is thrown

      Parameters

      • value: any

        The value to check.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      0.1.5

      That the value is falsy or throws the Error if it is an Error instance.

      assert.ifError(null);          // Passes - null is falsy
      assert.ifError(undefined); // Passes - undefined is falsy
      assert.ifError(false); // Passes - false is falsy
      assert.ifError(0); // Passes - 0 is falsy
      assert.ifError(""); // Passes - empty string is falsy

      // Throws the error itself
      assert.ifError(new Error("Something went wrong"));

      // Throws AssertionFailure
      assert.ifError(true); // Truthy but not an Error
      assert.ifError("error"); // Truthy but not an Error
      assert.ifError(1); // Truthy but not an Error
    • Asserts that the superset collection includes all members of the subset collection (order doesn't matter). Uses deep equality for comparison. Particularly useful for Maps which iterate over [key, value] pairs. Both arguments must conform to ArrayLikeOrSizedIterable but can be different concrete types.

      Type Parameters

      • T

      Parameters

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      assert.includeDeepMembers([{a: 1}, {b: 2}], [{a: 1}]);          // Passes
      assert.includeDeepMembers([[1, 2], [3, 4]], [[1, 2]]); // Passes
      assert.includeDeepMembers([{a: 1}, {b: 2}], new Set([{a: 1}])); // Passes - Array vs Set
      assert.includeDeepMembers(new Set([{a: 1}, {b: 2}]), [{a: 1}]); // Passes - Set vs Array

      // Maps iterate over [key, value] pairs
      const map = new Map([[1, "a"], [2, "b"], [3, "c"]]);
      assert.includeDeepMembers(map, [[1, "a"], [2, "b"]]); // Passes
      assert.includeDeepMembers([{a: 1}], [{a: 2}]); // Throws AssertionFailure
    • Asserts that the superset collection includes all members of the subset collection (order doesn't matter). Uses strict equality (===) for comparison. Both arguments must conform to ArrayLikeOrSizedIterable but can be different concrete types.

      Type Parameters

      • T

      Parameters

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      assert.includeMembers([1, 2, 3, 4], [2, 3]);                  // Passes - all members present
      assert.includeMembers([1, 2, 3, 4], new Set([2, 3])); // Passes - Array vs Set
      assert.includeMembers(new Set([1, 2, 3, 4]), [2, 3]); // Passes - Set vs Array
      assert.includeMembers(new Set([1, 2, 3, 4]), new Set([2, 3])); // Passes - Set vs Set
      assert.includeMembers([1, 2, 3], [1, 4]); // Throws AssertionFailure - 4 not present
    • Asserts that the provided value includes the specified match. The value can be a string, array, or any other type that supports the includes method. If the value does not include the match, it throws an AssertionFailure with the given message.

      Type Parameters

      • T

      Parameters

      • value: T

        The value to evaluate.

      • match: any

        The value to check for inclusion.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      0.1.2

      That the value includes the match and throws AssertionFailure if it does not.

      assert.includes("hello world", "world"); // Passes
      assert.includes([1, 2, 3], 2); // Passes
      assert.includes("hello world", "nomatch"); // Throws AssertionFailure
      assert.includes([1, 2, 3], 4); // Throws AssertionFailure
    • Asserts that executing the target function increases the monitored numeric value.

      Parameters

      • fn: () => void

        The function to execute that should increase the value.

      • getter: () => any

        A function that returns the value to monitor.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      let count = 0;
      const getCount = () => count;
      const increment = () => { count++; };
      assert.increases(increment, getCount);
    • Asserts that executing the target function increases the monitored object property.

      Type Parameters

      • T

      Parameters

      • fn: () => void

        The function to execute that should increase the value.

      • target: T

        An object containing the property to monitor.

      • prop: keyof T

        The property name to monitor.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      const obj = { count: 5 };
      const addFive = () => { obj.count += 5; };
      assert.increases(addFive, obj, 'count');
    • Asserts that executing the target function increases the monitored value but NOT by the specified delta. The value MUST increase, but the increase amount must not equal the specified delta.

      Parameters

      • fn: () => void

        The function to execute that should increase the value.

      • getter: () => any

        A function that returns the value to monitor.

      • delta: number

        The delta that should NOT match.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      let value = 0;
      const getValue = () => value;
      const addTwo = () => { value += 2; };
      assert.increasesButNotBy(addTwo, getValue, 5); // Passes - increased by 2, not 5
      assert.increasesButNotBy(addTwo, getValue, 2); // Fails - increased by exactly 2
    • Asserts that executing the target function increases the monitored object property but NOT by the specified delta. The value MUST increase, but the increase amount must not equal the specified delta.

      Type Parameters

      • T

      Parameters

      • fn: () => void

        The function to execute that should increase the value.

      • target: T

        An object containing the property to monitor.

      • prop: keyof T

        The property name to monitor.

      • delta: number

        The delta that should NOT match.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      const obj = { count: 10 };
      const addTwo = () => { obj.count += 2; };
      assert.increasesButNotBy(addTwo, obj, 'count', 5); // Passes - increased by 2, not 5
      assert.increasesButNotBy(addTwo, obj, 'count', 2); // Fails - increased by exactly 2
    • Asserts that executing the target function increases the monitored value by the specified delta.

      Parameters

      • fn: () => void

        The function to execute that should increase the value.

      • getter: () => any

        A function that returns the value to monitor.

      • delta: number

        The expected increase delta (must be positive).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      let value = 0;
      const getValue = () => value;
      const addFive = () => { value += 5; };
      assert.increasesBy(addFive, getValue, 5);
    • Asserts that executing the target function increases the monitored object property by the specified delta.

      Type Parameters

      • T

      Parameters

      • fn: () => void

        The function to execute that should increase the value.

      • target: T

        An object containing the property to monitor.

      • prop: keyof T

        The property name to monitor.

      • delta: number

        The expected increase delta (must be positive).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      const obj = { count: 10 };
      const addFive = () => { obj.count += 5; };
      assert.increasesBy(addFive, obj, 'count', 5);
    • Asserts that the given value is greater than the expected value.

      This method checks if the provided value is numerically greater than the expected value. Works with both numbers and Date objects.

      Parameters

      • value: number | Date

        The value to check.

      • expected: number | Date

        The expected value to compare against.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      0.1.5

      That value is greater than expected and throws AssertionFailure if it is not.

      assert.isAbove(5, 4); // Passes
      assert.isAbove(4, 5); // Throws AssertionFailure
      assert.isAbove(new Date(2024, 1, 2), new Date(2024, 1, 1)); // Passes
    • Asserts that the value is an array.

      Parameters

      • value: any

        The value to check.

      • OptionalinitMsg: MsgSource

        The custom message to display if the assertion fails.

      Returns AssertInst

      An AssertionFailure if the value is not a number.

      assert.isArray([]); // Passes
      assert.isArray([1, 2, 3]); // Passes
      assert.isArray({}); // Throws AssertionFailure
      assert.isArray(null); // Throws AssertionFailure
      assert.isArray(undefined); // Throws AssertionFailure
    • Asserts that the given value is greater than or equal to the expected value.

      This method checks if the provided value is numerically greater than or equal to the expected value. Works with both numbers and Date objects.

      Parameters

      • value: number | Date

        The value to check.

      • expected: number | Date

        The expected value to compare against.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      0.1.5

      That value is greater than or equal to expected and throws AssertionFailure if it is not.

      assert.isAtLeast(5, 4); // Passes
      assert.isAtLeast(5, 5); // Passes
      assert.isAtLeast(4, 5); // Throws AssertionFailure
    • Asserts that the given value is less than or equal to the expected value.

      This method checks if the provided value is numerically less than or equal to the expected value. Works with both numbers and Date objects.

      Parameters

      • value: number | Date

        The value to check.

      • expected: number | Date

        The expected value to compare against.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      0.1.5

      That value is less than or equal to expected and throws AssertionFailure if it is not.

      assert.isAtMost(4, 5); // Passes
      assert.isAtMost(5, 5); // Passes
      assert.isAtMost(5, 4); // Throws AssertionFailure
    • Asserts that the given value is less than the expected value.

      This method checks if the provided value is numerically less than the expected value. Works with both numbers and Date objects.

      Parameters

      • value: number | Date

        The value to check.

      • expected: number | Date

        The expected value to compare against.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      0.1.5

      That value is less than expected and throws AssertionFailure if it is not.

      assert.isBelow(4, 5); // Passes
      assert.isBelow(5, 4); // Throws AssertionFailure
    • Asserts that the value is a boolean.

      Parameters

      • value: any

        The value to check.

      • OptionalinitMsg: MsgSource

        The custom message to display if the assertion fails.

      Returns AssertInst

      An AssertionFailure if the value is not a boolean.

      0.1.5

      assert.isBoolean(true); // Passes
      assert.isBoolean(false); // Passes
      assert.isBoolean(1); // Throws AssertionFailure
      assert.isBoolean("true"); // Throws AssertionFailure
      assert.isBoolean(null); // Throws AssertionFailure
      assert.isBoolean(undefined); // Throws AssertionFailure
    • Asserts that the provided value is empty, for strings, arrays, and objects, it checks if their length or size is zero. If the value is not empty, it throws an AssertionFailure with the given message.

      Parameters

      • value: any

        The value to check.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value is empty and throws AssertionFailure if it is not.

      assert.isEmpty(""); // Passes
      assert.isEmpty([]); // Passes
      assert.isEmpty({}); // Passes
      assert.isEmpty("non-empty"); // Throws AssertionFailure
      assert.isEmpty([1, 2, 3]); // Throws AssertionFailure
      assert.isEmpty({ key: "value" }); // Throws AssertionFailure
    • This method checks if the provided value is an instance of the specified error or error constructor. If the value is not an instance of the specified error or error constructor, it throws an AssertionFailure with the given message.

      Type Parameters

      • T

      Parameters

      • value: T

        The value to evaluate.

      • OptionalerrorLike: Error | ErrorConstructor

        The error or error constructor to check against.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value is an instance of the specified error or error constructor and throws AssertionFailure if it is not.

      assert.isError(new Error()); // Passes
      assert.isError(new TypeError(), TypeError); // Passes
      assert.isError(new Error(), TypeError); // Throws AssertionFailure
      assert.isError({}, Error); // Throws AssertionFailure
      assert.isError(null, Error); // Throws AssertionFailure
    • Asserts whether the value is extensible indicating whether new properties can be added to it. Primitive values are not extensible.

      Parameters

      • value: any

        The value to check.

      • OptionalinitMsg: MsgSource

        The custom message to display if the assertion fails.

      Returns AssertInst

      An AssertionFailure if the value is not extensible.

      assert.isExtensible({}); // Passes
      assert.isExtensible([]); // Passes
      assert.isExtensible(Object.create(null)); // Passes
      assert.isExtensible(Object.freeze({})); // Throws AssertionFailure
      assert.isExtensible(Object.seal({})); // Throws AssertionFailure
    • Asserts that the given value is false.

      This method checks if the provided value is strictly equal to false. If the value is not false, it throws an AssertionFailure with the given message.

      Parameters

      • value: unknown

        The value to check.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value is strictly false and throws AssertionFailure if it is not.

      assert.isFalse(false); // Passes
      assert.isFalse(true); // Throws AssertionFailure
      assert.isFalse(0); // Throws AssertionFailure
      assert.isFalse(""); // Throws AssertionFailure
    • Asserts that the given value is a finite number (not NaN, not Infinity, not -Infinity).

      Parameters

      • value: any

        The value to check.

      • OptionalinitMsg: MsgSource

        The custom message to display if the assertion fails.

      Returns AssertInst

      An AssertionFailure if the value is not a finite number.

      0.1.5

      assert.isFinite(123); // Passes
      assert.isFinite(0); // Passes
      assert.isFinite(-456.789); // Passes
      assert.isFinite(NaN); // Throws AssertionFailure
      assert.isFinite(Infinity); // Throws AssertionFailure
      assert.isFinite(-Infinity); // Throws AssertionFailure
      assert.isFinite("123"); // Throws AssertionFailure
      assert.isFinite(null); // Throws AssertionFailure
      assert.isFinite(undefined); // Throws AssertionFailure
    • Asserts that the provided value is frozen and cannot have new properties added to it and its existing properties cannot be removed. If the value is not frozen, it throws an AssertionFailure with the given message.

      Parameters

      • value: any

        The value to check.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value is frozen and throws AssertionFailure if it is not.

      assert.isFrozen(Object.freeze({})); // Passes
      assert.isFrozen(Object.freeze([])); // Passes
      assert.isFrozen(Object.freeze("string")); // Passes
      assert.isFrozen(Object.freeze({ key: "value" })); // Passes
      assert.isFrozen({}); // Throws AssertionFailure
      assert.isFrozen([]); // Throws AssertionFailure
      assert.isFrozen("string"); // Throws AssertionFailure
      assert.isFrozen({ key: "value" }); // Throws AssertionFailure
    • This method checks if the provided value is a function. If the value is not a function, it throws an AssertionFailure with the given message.

      Parameters

      • value: any

        The value to evaluate.

      • OptionalinitMsg: MsgSource

        The message to display if value is not a function.

      Returns AssertInst

      That the value is a function and throws AssertionFailure if it is not.

      assert.isFunction(() => {}); // Passes
      assert.isFunction(function() {}); // Passes
      assert.isFunction(async function() {}); // Passes
      assert.isFunction(null); // Throws AssertionFailure
      assert.isFunction(123); // Throws AssertionFailure
      assert.isFunction("string"); // Throws AssertionFailure
    • Asserts that the given value is an instance of the specified constructor. Uses the JavaScript instanceof operator to check if the value is an instance of the constructor.

      Parameters

      • value: any

        The value to check.

      • constructor: Function

        The constructor function to check against (e.g., Array, Date, Error, custom class).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      An AssertionFailure if the value is not an instance of the constructor.

      0.1.5

      assert.isInstanceOf(new Date(), Date); // Passes
      assert.isInstanceOf([], Array); // Passes
      assert.isInstanceOf(new Error(), Error); // Passes
      assert.isInstanceOf({}, Object); // Passes
      class MyClass {}
      assert.isInstanceOf(new MyClass(), MyClass); // Passes
      assert.isInstanceOf("hello", String); // Throws AssertionFailure
      assert.isInstanceOf(123, Number); // Throws AssertionFailure
      assert.isInstanceOf([], Object); // Passes (arrays are objects)
      assert.isInstanceOf({}, Array); // Throws AssertionFailure
    • Asserts that the given value is an iterable, meaning it has a Symbol.iterator property.

      Parameters

      • value: any

        The value to check.

      • OptionalinitMsg: MsgSource

        The custom message to display if the assertion fails.

      Returns AssertInst

      An AssertionFailure if the value is not an iterable.

      assert.isIterable([]); // Passes
      assert.isIterable(new Map()); // Passes
      assert.isIterable(new Set()); // Passes
      assert.isIterable({ [Symbol.iterator]: () => {} }); // Passes
      assert.isIterable({}); // Throws AssertionFailure
      assert.isIterable(null); // Throws AssertionFailure
      assert.isIterable(undefined); // Throws AssertionFailure
    • Asserts that the given value is NaN.

      This method checks if the provided value is the special numeric value NaN (Not-a-Number). Note that this only passes for actual NaN values, not for non-numeric types.

      Parameters

      • value: any

        The value to check.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value is NaN and throws AssertionFailure if it is not.

      0.1.5

      assert.isNaN(NaN); // Passes
      assert.isNaN(Number.NaN); // Passes
      assert.isNaN(0 / 0); // Passes
      assert.isNaN(123); // Throws AssertionFailure
      assert.isNaN("hello"); // Throws AssertionFailure
      assert.isNaN(undefined); // Throws AssertionFailure
      assert.isNaN(null); // Throws AssertionFailure
    • Asserts that the given value is not greater than the expected value.

      This method checks if the provided value is not numerically greater than the expected value. Works with both numbers and Date objects. This is the inverse of isAbove.

      Parameters

      • value: number | Date

        The value to check.

      • expected: number | Date

        The expected value to compare against.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      0.1.5

      That value is not greater than expected and throws AssertionFailure if it is.

      assert.isNotAbove(4, 5); // Passes
      assert.isNotAbove(5, 5); // Passes
      assert.isNotAbove(5, 4); // Throws AssertionFailure
    • Asserts that the value is not an array.

      Parameters

      • value: any

        The value to check.

      • OptionalinitMsg: MsgSource

        The custom message to display if the assertion fails.

      Returns AssertInst

      An AssertionFailure if the value is an array.

      assert.isNotArray({}); // Passes
      assert.isNotArray(123); // Passes
      assert.isNotArray("hello"); // Passes
      assert.isNotArray(null); // Passes
      assert.isNotArray(undefined); // Passes
      assert.isNotArray([]); // Throws AssertionFailure
      assert.isNotArray([1, 2, 3]); // Throws AssertionFailure
    • Asserts that the given value is not greater than or equal to the expected value.

      This method checks if the provided value is not numerically greater than or equal to the expected value. Works with both numbers and Date objects. This is the inverse of isAtLeast.

      Parameters

      • value: number | Date

        The value to check.

      • expected: number | Date

        The expected value to compare against.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      0.1.5

      That value is not greater than or equal to expected and throws AssertionFailure if it is.

      assert.isNotAtLeast(4, 5); // Passes
      assert.isNotAtLeast(5, 5); // Throws AssertionFailure
      assert.isNotAtLeast(5, 4); // Throws AssertionFailure
    • Asserts that the given value is not less than or equal to the expected value.

      This method checks if the provided value is not numerically less than or equal to the expected value. Works with both numbers and Date objects. This is the inverse of isAtMost.

      Parameters

      • value: number | Date

        The value to check.

      • expected: number | Date

        The expected value to compare against.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      0.1.5

      That value is not less than or equal to expected and throws AssertionFailure if it is.

      assert.isNotAtMost(5, 4); // Passes
      assert.isNotAtMost(5, 5); // Throws AssertionFailure
      assert.isNotAtMost(4, 5); // Throws AssertionFailure
    • Asserts that the given value is not less than the expected value.

      This method checks if the provided value is not numerically less than the expected value. Works with both numbers and Date objects. This is the inverse of isBelow.

      Parameters

      • value: number | Date

        The value to check.

      • expected: number | Date

        The expected value to compare against.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      0.1.5

      That value is not less than expected and throws AssertionFailure if it is.

      assert.isNotBelow(5, 4); // Passes
      assert.isNotBelow(5, 5); // Passes
      assert.isNotBelow(4, 5); // Throws AssertionFailure
    • Asserts that the value is not a boolean.

      Parameters

      • value: any

        The value to check.

      • OptionalinitMsg: MsgSource

        The custom message to display if the assertion fails.

      Returns AssertInst

      An AssertionFailure if the value is a boolean.

      0.1.5

      assert.isNotBoolean(123); // Passes
      assert.isNotBoolean("hello"); // Passes
      assert.isNotBoolean(null); // Passes
      assert.isNotBoolean(true); // Throws AssertionFailure
      assert.isNotBoolean(false); // Throws AssertionFailure
    • Asserts that the provided value is not empty, for strings, arrays, and objects, it checks if their length or size is greater than zero. If the value is empty, it throws an AssertionFailure with the given message.

      Parameters

      • value: any

        The value to check.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value is not empty and throws AssertionFailure if it is.

      assert.isNotEmpty("non-empty"); // Passes
      assert.isNotEmpty([1, 2, 3]); // Passes
      assert.isNotEmpty({ key: "value" }); // Passes
      assert.isNotEmpty(""); // Throws AssertionFailure
      assert.isNotEmpty([]); // Throws AssertionFailure
      assert.isNotEmpty({}); // Throws AssertionFailure
    • Asserts whether the value is not extensible indicating whether new properties can be added to it. Primitive values are not extensible.

      Parameters

      • value: any

        The value to check.

      • OptionalinitMsg: MsgSource

        The custom message to display if the assertion fails

      Returns AssertInst

      An AssertionFailure if the value is extensible.

      assert.isNotExtensible(Object.freeze({})); // Passes
      assert.isNotExtensible(Object.seal({})); // Passes
      assert.isNotExtensible({}); // Throws AssertionFailure
      assert.isNotExtensible([]); // Throws AssertionFailure
      assert.isNotExtensible(Object.create(null)); // Throws AssertionFailure
    • Asserts that the given value is not false.

      This method checks if the provided value is not strictly equal to false. If the value is false, it throws an AssertionFailure with the given message.

      Parameters

      • value: unknown

        The value to check.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value is not strictly false and throws AssertionFailure if it is.

      assert.isNotFalse(true); // Passes
      assert.isNotFalse(1); // Passes
      assert.isNotFalse("false"); // Passes
      assert.isNotFalse(false); // Throws AssertionFailure
    • Asserts that the given value is not a finite number (e.g., NaN, Infinity, -Infinity, or non-numeric).

      Parameters

      • value: any

        The value to check.

      • OptionalinitMsg: MsgSource

        The custom message to display if the assertion fails.

      Returns AssertInst

      An AssertionFailure if the value is a finite number.

      0.1.5

      assert.isNotFinite(NaN); // Passes
      assert.isNotFinite(Infinity); // Passes
      assert.isNotFinite(-Infinity); // Passes
      assert.isNotFinite("123"); // Passes
      assert.isNotFinite(null); // Passes
      assert.isNotFinite(undefined); // Passes
      assert.isNotFinite({}); // Passes
      assert.isNotFinite(123); // Throws AssertionFailure
      assert.isNotFinite(0); // Throws AssertionFailure
      assert.isNotFinite(-456.789); // Throws AssertionFailure
    • Asserts that the provided value is not frozen and can have new properties added to it and its existing properties can be removed. If the value is frozen, it throws an AssertionFailure with the given message.

      Parameters

      • value: any

        The value to check.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value is not frozen and throws AssertionFailure if it is.

      assert.isNotFrozen({}); // Passes
      assert.isNotFrozen([]); // Passes
      assert.isNotFrozen("string"); // Passes
      assert.isNotFrozen({ key: "value" }); // Passes
      assert.isNotFrozen(Object.freeze({})); // Throws AssertionFailure
      assert.isNotFrozen(Object.freeze([])); // Throws AssertionFailure
      assert.isNotFrozen(Object.freeze("string")); // Throws AssertionFailure
      assert.isNotFrozen(Object.freeze({ key: "value" })); // Throws AssertionFailure
    • This method checks if the provided value is not a function. If the value is a function, it throws an AssertionFailure with the given message.

      Parameters

      • value: any

        The value to evaluate.

      • OptionalinitMsg: MsgSource

        The message to display if value is a function.

      Returns AssertInst

      That the value is not a function and throws AssertionFailure if it is.

      assert.isNotFunction(null); // Passes
      assert.isNotFunction(123); // Passes
      assert.isNotFunction("string"); // Passes
      assert.isNotFunction(() => {}); // Throws AssertionFailure
      assert.isNotFunction(function() {}); // Throws AssertionFailure
      assert.isNotFunction(async function() {}); // Throws AssertionFailure
    • Asserts that the given value is not an instance of the specified constructor. Uses the JavaScript instanceof operator to check if the value is not an instance of the constructor.

      Parameters

      • value: any

        The value to check.

      • constructor: Function

        The constructor function to check against (e.g., Array, Date, Error, custom class).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      An AssertionFailure if the value is an instance of the constructor.

      0.1.5

      assert.isNotInstanceOf("hello", Number); // Passes
      assert.isNotInstanceOf(123, String); // Passes
      assert.isNotInstanceOf({}, Array); // Passes
      assert.isNotInstanceOf([], Date); // Passes
      assert.isNotInstanceOf(new Date(), Date); // Throws AssertionFailure
      assert.isNotInstanceOf([], Array); // Throws AssertionFailure
    • Asserts that the given value is not an iterable, meaning it does not have a Symbol.iterator property.

      Parameters

      • value: any

        The value to check.

      • OptionalinitMsg: MsgSource

        The custom message to display if the assertion fails.

      Returns AssertInst

      An AssertionFailure if the value is an iterable.

      assert.isNotIterable({}); // Passes
      assert.isNotIterable(null); // Passes
      assert.isNotIterable(undefined); // Passes
      assert.isNotIterable([]); // Throws AssertionFailure
      assert.isNotIterable(new Map()); // Throws AssertionFailure
      assert.isNotIterable(new Set()); // Throws AssertionFailure
      assert.isNotIterable({ [Symbol.iterator]: () => {} }); // Throws AssertionFailure
    • Asserts that the given value is not NaN.

      This method checks if the provided value is not the special numeric value NaN (Not-a-Number).

      Parameters

      • value: any

        The value to check.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value is not NaN and throws AssertionFailure if it is.

      0.1.5

      assert.isNotNaN(123); // Passes
      assert.isNotNaN(0); // Passes
      assert.isNotNaN("hello"); // Passes
      assert.isNotNaN(undefined); // Passes
      assert.isNotNaN(null); // Passes
      assert.isNotNaN(NaN); // Throws AssertionFailure
      assert.isNotNaN(Number.NaN); // Throws AssertionFailure
    • Asserts that the given value is not null.

      This method checks if the provided value is not strictly equal to null. If the value is null, it throws an AssertionFailure with the given message.

      Type Parameters

      • T

      Parameters

      • value: T

        The value to check.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value is not strictly null and throws AssertionFailure if it is.

      assert.isNotNull(1); // Passes
      assert.isNotNull("string"); // Passes
      assert.isNotNull(undefined); // Passes
      assert.isNotNull(null); // Throws AssertionFailure
    • Asserts that the value is not a number.

      Parameters

      • value: any

        The value to check.

      • OptionalinitMsg: MsgSource

        The custom message to display if the assertion fails.

      Returns AssertInst

      An AssertionFailure if the value is a number.

      0.1.5

      assert.isNotNumber("hello"); // Passes
      assert.isNotNumber({}); // Passes
      assert.isNotNumber(null); // Passes
      assert.isNotNumber(123); // Throws AssertionFailure
      assert.isNotNumber(3.14); // Throws AssertionFailure
    • This method checks if the provided value is not an object. If the value is an object, it throws an AssertionFailure with the given message.

      Type Parameters

      • T

      Parameters

      • value: T

        The value to evaluate.

      • OptionalinitMsg: MsgSource

        The message to display if value is an object.

      Returns AssertInst

      That the value is not an object and throws AssertionFailure if it is.

      assert.isNotObject(null); // Passes
      assert.isNotObject(123); // Passes
      assert.isNotObject("string"); // Passes
      assert.isNotObject({}); // Throws AssertionFailure
      assert.isNotObject([]); // Throws AssertionFailure
    • Throws an AssertionFailure with the given message if value is not falsy. This method is used to assert that a value is falsy.

      Type Parameters

      • T

        The type of the value.

      Parameters

      • value: T

        The value to evaluate. If the value is not falsy, an AssertionFailure is thrown.

      • OptionalinitMsg: MsgSource

        The message to display if value is not falsy. This can be a string or a function returning a string.

      Returns AssertInst

      That the value is not truthy (falsy) and throws AssertionFailure if it is not.

      assert.isNotOk(0); // Passes
      assert.isNotOk(1); // Throws AssertionFailure
      assert.isNotOk(true); // Throws AssertionFailure
      assert.isNotOk(false); // Passes
      assert.isNotOk(null); // Passes
      assert.isNotOk(undefined); // Passes
      assert.isNotOk(""); // Passes
      assert.isNotOk("a"); // Throws AssertionFailure
      assert.isNotOk([]); // Throws AssertionFailure
      assert.isNotOk([1, 2]); // Throws AssertionFailure
      assert.isNotOk({}); // Throws AssertionFailure
      assert.isNotOk({ a: 1 }); // Throws AssertionFailure
      assert.isNotOk(new Map()); // Throws AssertionFailure
      assert.isNotOk(new Map([["a", 1]])); // Throws AssertionFailure
      assert.isNotOk(new Set()); // Throws AssertionFailure
      assert.isNotOk(new Set([1, 2])); // Throws AssertionFailure
      assert.isNotOk(new Date()); // Throws AssertionFailure
    • This method checks if the provided value is not a plain object. If the value is a plain object, it throws an AssertionFailure with the given message.

      A plain object is an object created by the object literal {} or with new Object(). It does not include instances of classes, arrays, or other objects.

      Type Parameters

      • T

      Parameters

      • value: T

        The value to evaluate.

      • OptionalinitMsg: MsgSource

        The message to display if value is a plain object.

      Returns AssertInst

      That the value is not a plain object and throws AssertionFailure if it is.

      assert.isNotPlainObject([]); // Passes
      assert.isNotPlainObject(null); // Passes
      assert.isNotPlainObject(123); // Passes
      assert.isNotPlainObject("string"); // Passes
      assert.isNotPlainObject({}); // Throws AssertionFailure
      assert.isNotPlainObject(Object.create(null)); // Throws AssertionFailure
      assert.isNotPlainObject(new Object()); // Throws AssertionFailure
    • Asserts that the provided value is not sealed and can have new properties added to it. If the value is sealed, it throws an AssertionFailure with the given message.

      Parameters

      • value: any

        The value to check.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value is not sealed and throws AssertionFailure if it is.

      assert.isNotSealed({}); // Passes
      assert.isNotSealed([]); // Passes
      assert.isNotSealed({ key: "value" }); // Passes
      assert.isNotSealed(Object.seal({})); // Throws AssertionFailure
      assert.isNotSealed(Object.seal([])); // Throws AssertionFailure
      assert.isNotSealed(Object.seal({ key: "value" })); // Throws AssertionFailure
    • Asserts that the value is not a string.

      Parameters

      • value: any

        The value to check.

      • OptionalinitMsg: MsgSource

        The custom message to display if the assertion fails.

      Returns AssertInst

      An AssertionFailure if the value is a string.

      assert.isNotString(123); // Passes
      assert.isNotString({}); // Passes
      assert.isNotString("hello"); // Throws AssertionFailure
      assert.isNotString(null); // Passes
      assert.isNotString(undefined); // Passes
    • Asserts that the given value is not true.

      This method checks if the provided value is not strictly equal to true. If the value is true, it throws an AssertionFailure with the given message.

      Parameters

      • value: unknown

        The value to check.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value is not strictly true and throws AssertionFailure if it is.

      assert.isNotTrue(false); // Passes
      assert.isNotTrue(0); // Passes
      assert.isNotTrue(""); // Passes
      assert.isNotTrue(true); // Throws AssertionFailure
    • Asserts that the given value is not strictly undefined.

      Type Parameters

      • T

      Parameters

      • value: T

        The value to check.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value is not strictly undefined and throws AssertionFailure if it is.

      assert.isNotUndefined(1); // Passes
      assert.isNotUndefined("string"); // Passes
      assert.isNotUndefined(null); // Passes
      assert.isNotUndefined(undefined); // Throws AssertionFailure
    • Asserts that the given value is not within the specified range (inclusive).

      This method checks if the provided value is not within the given range. The range is inclusive, meaning the start and finish values are included. Works with both numbers and Date objects. This is the inverse of isWithin.

      Parameters

      • value: number | Date

        The value to check.

      • start: number | Date

        The start of the range (inclusive).

      • finish: number | Date

        The end of the range (inclusive).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      0.1.5

      That value is not within start..finish and throws AssertionFailure if it is.

      assert.isNotWithin(0, 1, 10); // Passes
      assert.isNotWithin(11, 1, 10); // Passes
      assert.isNotWithin(5, 1, 10); // Throws AssertionFailure
      assert.isNotWithin(1, 1, 10); // Throws AssertionFailure
      assert.isNotWithin(10, 1, 10); // Throws AssertionFailure
    • Asserts that the given value is null.

      This method checks if the provided value is strictly equal to null. If the value is not null, it throws an AssertionFailure with the given message.

      Type Parameters

      • T

      Parameters

      • value: T

        The value to check.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value is strictly null and throws AssertionFailure if it is not.

      assert.isNull(null); // Passes
      assert.isNull(undefined); // Throws AssertionFailure
      assert.isNull(0); // Throws AssertionFailure
      assert.isNull(""); // Throws AssertionFailure
    • Asserts that the value is a number.

      Parameters

      • value: any

        The value to check.

      • OptionalinitMsg: MsgSource

        The custom message to display if the assertion fails.

      Returns AssertInst

      An AssertionFailure if the value is not a number.

      0.1.5

      assert.isNumber(123); // Passes
      assert.isNumber(3.14); // Passes
      assert.isNumber(0); // Passes
      assert.isNumber("123"); // Throws AssertionFailure
      assert.isNumber(null); // Throws AssertionFailure
      assert.isNumber(undefined); // Throws AssertionFailure
    • This method checks if the provided value is an object. If the value is not an object, it throws an AssertionFailure with the given message.

      Type Parameters

      • T

      Parameters

      • value: T

        The value to evaluate.

      • OptionalinitMsg: MsgSource

        The message to display if value is not an object.

      Returns AssertInst

      That the value is an object and throws AssertionFailure if it is not.

      assert.isObject({}); // Passes
      assert.isObject([]); // Passes
      assert.isObject(null); // Throws AssertionFailure
      assert.isObject(123); // Throws AssertionFailure
      assert.isObject("string"); // Throws AssertionFailure
    • Throws an AssertionFailure with the given message if value is not truthy. This method is used to assert that a value is truthy.

      Type Parameters

      • T

        The type of the value.

      Parameters

      • value: T

        The value to evaluate. If the value is not truthy, an AssertionFailure is thrown.

      • OptionalinitMsg: MsgSource

        The message to display if value is not truthy. This can be a string or a function returning a string.

      Returns AssertInst

      That the value is truthy and throws AssertionFailure if it is not.

      assert.isOk(1); // Passes
      assert.isOk("a"); // Passes
      assert.isOk([]); // Passes
      assert.isOk({}); // Passes
      assert.isOk(new Map()); // Passes
      assert.isOk(new Set()); // Passes
      assert.isOk(new Date()); // Passes
      assert.isOk(true); // Passes
      assert.isOk(false); // Throws AssertionFailure
      assert.isOk(0, "Value should be truthy"); // Throws AssertionFailure with message "Value should be truthy"
      assert.isOk(""); // Throws AssertionFailure
      assert.isOk(null); // Throws AssertionFailure
      assert.isOk(undefined); // Throws AssertionFailure
    • This method checks if the provided value is a plain object. If the value is not a plain object, it throws an AssertionFailure with the given message.

      A plain object is an object created by the object literal {} or with new Object(). It does not include instances of classes, arrays, or other objects.

      Type Parameters

      • T

      Parameters

      • value: T

        The value to evaluate.

      • OptionalinitMsg: MsgSource

        The message to display if value is not a plain object.

      Returns AssertInst

      That the value is a plain object and throws AssertionFailure if it is not.

      assert.isPlainObject({}); // Passes
      assert.isPlainObject(Object.create(null)); // Passes
      assert.isPlainObject(new Object()); // Passes
      assert.isPlainObject([]); // Throws AssertionFailure
      assert.isPlainObject(null); // Throws AssertionFailure
      assert.isPlainObject(123); // Throws AssertionFailure
      assert.isPlainObject("string"); // Throws AssertionFailure
    • Asserts that the provided value is sealed and cannot have any new properties added to it. If the value is not sealed, it throws an AssertionFailure with the given message.

      Parameters

      • value: any

        The value to check.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value is sealed and throws AssertionFailure if it is not.

      assert.isSealed(Object.seal({})); // Passes
      assert.isSealed(Object.seal([])); // Passes
      assert.isSealed(Object.seal({ key: "value" })); // Passes
      assert.isSealed({}); // Throws AssertionFailure
      assert.isSealed([]); // Throws AssertionFailure
      assert.isSealed({ key: "value" }); // Throws AssertionFailure
    • Asserts that the value is a string.

      Parameters

      • value: any

        The value to check.

      • OptionalinitMsg: MsgSource

        The custom message to display if the assertion fails.

      Returns AssertInst

      An AssertionFailure if the value is not a string.

      assert.isString("hello"); // Passes
      assert.isString(123); // Throws AssertionFailure
      assert.isString(null); // Throws AssertionFailure
      assert.isString(undefined); // Throws AssertionFailure
    • Asserts that the given value is true.

      This method checks if the provided value is strictly equal to true. If the value is not true, it throws an AssertionFailure with the given message.

      Parameters

      • value: unknown

        The value to check.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value is strictly true and throws AssertionFailure if it is not.

      assert.isTrue(true); // Passes
      assert.isTrue(false); // Throws AssertionFailure
      assert.isTrue(1); // Throws AssertionFailure
      assert.isTrue("true"); // Throws AssertionFailure
    • Asserts that the given value is strictly undefined.

      Type Parameters

      • T

      Parameters

      • value: T

        The value to check.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value is strictly undefined and throws AssertionFailure if it is not.

      assert.isUndefined(undefined); // Passes
      assert.isUndefined(null); // Throws AssertionFailure
      assert.isUndefined(0); // Throws AssertionFailure
      assert.isUndefined(""); // Throws AssertionFailure
    • Asserts that the given value is within the specified range (inclusive).

      This method checks if the provided value is between the start and finish values (inclusive). Works with both numbers and Date objects.

      Parameters

      • value: number | Date

        The value to check.

      • start: number | Date

        The start of the range (inclusive).

      • finish: number | Date

        The end of the range (inclusive).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      0.1.5

      That value is within the range [start, finish] and throws AssertionFailure if it is not.

      assert.isWithin(5, 1, 10); // Passes
      assert.isWithin(5, 5, 10); // Passes
      assert.isWithin(5, 1, 5); // Passes
      assert.isWithin(0, 1, 10); // Throws AssertionFailure
      assert.isWithin(11, 1, 10); // Throws AssertionFailure
    • Asserts that the target has a length or size property equal to the given number.

      Works with arrays, strings, Maps, Sets, and any object with a length or size property.

      Type Parameters

      • T extends { length?: number } | { size?: number }

      Parameters

      • object: T

        The object to check (array, string, Map, Set, or any object with length/size).

      • length: number

        The expected length or size.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      0.1.5

      That object has a length or size equal to length and throws AssertionFailure if it does not.

      assert.lengthOf([1, 2, 3], 3); // Passes
      assert.lengthOf("hello", 5); // Passes
      assert.lengthOf(new Map([["a", 1]]), 1); // Passes
      assert.lengthOf(new Set([1, 2]), 2); // Passes
      assert.lengthOf([1, 2], 3); // Throws AssertionFailure
    • Asserts that the provided value matches the specified regular expression. If the value does not match the regular expression, it throws an AssertionFailure with the given message.

      Type Parameters

      • T

      Parameters

      • value: T

        The value to evaluate.

      • regexp: RegExp

        The regular expression to match against.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value matches the regular expression and throws AssertionFailure if it does not.

      assert.match("hello world", /hello/); // Passes
      assert.match("hello world", /^hello world$/); // Passes
      assert.match("hello world", /world$/); // Passes
      assert.match("hello world", /nomatch/); // Throws AssertionFailure
    • Asserts that the value contains the expected using nested property matching. Each property in the expected is matched against the value using dot notation.

      Type Parameters

      • T

      Parameters

      • value: T

        The object to search in.

      • expected: any

        The object with properties to match (can use dot notation for keys).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value contains the expected using nested property matching and throws AssertionFailure if it does not.

      0.1.5

      assert.nestedInclude({ a: { b: { c: 1 } } }, { 'a.b.c': 1 }); // Passes
      assert.nestedInclude({ a: { b: { c: 1 } }, d: 2 }, { 'a.b': { c: 1 } }); // Passes
      assert.nestedInclude({ a: { b: { c: 1 } } }, { 'a.b.c': 2 }); // Throws AssertionFailure
    • Asserts that the provided value has the specified nested property using dot notation (e.g., "a.b.c"). Optionally checks the property value using loose equality (==). If the value does not have the nested property or the value doesn't match, it throws an AssertionFailure with the given message.

      Type Parameters

      • T

      Parameters

      • target: T

        The value to evaluate.

      • path: string

        The dot-separated path to the property (e.g., "a.b.c").

      • Optionalvalue: any

        Optional. The expected value of the property (uses loose equality).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value has the specified nested property and throws AssertionFailure if it does not.

      0.1.5

      assert.nestedProperty({ a: { b: { c: 1 } } }, "a.b.c"); // Passes
      assert.nestedProperty({ a: { b: 2 } }, "a.b.c"); // Throws AssertionFailure
      assert.nestedProperty({ a: { b: { c: 1 } } }, "a.b.c", 1); // Passes
      assert.nestedProperty({ a: { b: { c: 1 } } }, "a.b.c", "1"); // Passes (loose equality)
      assert.nestedProperty({ a: { b: { c: 1 } } }, "a.b.c", 2); // Throws AssertionFailure
    • Alias for notCloseTo. Asserts that the actual value is NOT approximately equal to the expected value within the specified delta. This is the inverse of approximately.

      Parameters

      • actual: number

        The actual value to check. Must be a number.

      • expected: number

        The expected value to compare against. Must be a number.

      • delta: number

        The maximum allowed difference. Must be a number. Note: A negative delta will always result in a passing assertion since the absolute difference is always non-negative.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      notCloseTo

      0.1.5

      assert.notApproximately(2, 1.0, 0.5);   // Passes - difference is 1.0 which is > 0.5
      assert.notApproximately(1.5, 1.0, 0.5); // Throws AssertionFailure - difference is 0.5
    • Asserts that the value does NOT change by the specified delta after executing the target function. The value may remain unchanged, or change by a different amount. This is the negation of changesBy. For asserting that a change MUST occur but not by the specified amount, use changesButNotBy.

      Parameters

      • fn: () => void

        The function to execute.

      • getter: () => any

        A function that returns the value to monitor.

      • delta: number

        The delta that should NOT match.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      let value = 0;
      const getValue = () => value;
      const addTwo = () => { value += 2; };
      const noOp = () => {};
      assert.notChangesBy(addTwo, getValue, 5); // Passes - changed by 2, not by 5
      assert.notChangesBy(noOp, getValue, 5); // Passes - no change at all (not by 5)
      assert.notChangesBy(addTwo, getValue, 2); // Fails - changed by exactly 2
    • Asserts that the property does NOT change by the specified delta after executing the target function. The value may remain unchanged, or change by a different amount. This is the negation of changesBy. For asserting that a change MUST occur but not by the specified amount, use changesButNotBy.

      Type Parameters

      • T

      Parameters

      • fn: () => void

        The function to execute.

      • target: T

        An object containing the property to monitor.

      • prop: keyof T

        The property name to monitor.

      • delta: number

        The delta that should NOT match.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      const obj = { count: 10 };
      const addTwo = () => { obj.count += 2; };
      const noOp = () => {};
      assert.notChangesBy(addTwo, obj, 'count', 5); // Passes - changed by 2, not by 5
      assert.notChangesBy(noOp, obj, 'count', 5); // Passes - no change at all (not by 5)
      assert.notChangesBy(addTwo, obj, 'count', 2); // Fails - changed by exactly 2
    • Asserts that the actual value is NOT close to the expected value within the specified delta. This is the inverse of closeTo.

      Parameters

      • actual: number

        The actual value to check. Must be a number.

      • expected: number

        The expected value to compare against. Must be a number.

      • delta: number

        The maximum allowed difference. Must be a number. Note: A negative delta will always result in a passing assertion since the absolute difference is always non-negative.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      assert.notCloseTo(2, 1.0, 0.5);   // Passes - difference is 1.0 which is > 0.5
      assert.notCloseTo(-10, 20, 29); // Passes - difference is 30 which is > 29
      assert.notCloseTo(1.5, 1.0, 0.5); // Throws AssertionFailure - difference is 0.5
    • Asserts that executing the target function decreases the monitored value but NOT by the specified delta.

      Parameters

      • fn: () => void

        The function to execute that should decrease the value.

      • getter: () => any

        A function that returns the value to monitor.

      • delta: number

        The delta that should NOT match.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      let value = 10;
      const getValue = () => value;
      const subtractTwo = () => { value -= 2; };
      assert.notDecreasesBy(subtractTwo, getValue, 5); // Passes - decreased by 2, not 5
    • Asserts that executing the target function decreases the monitored object property but NOT by the specified delta.

      Type Parameters

      • T

      Parameters

      • fn: () => void

        The function to execute that should decrease the value.

      • target: T

        An object containing the property to monitor.

      • prop: keyof T

        The property name to monitor.

      • delta: number

        The delta that should NOT match.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      const obj = { count: 10 };
      const subtractTwo = () => { obj.count -= 2; };
      assert.notDecreasesBy(subtractTwo, obj, 'count', 5); // Passes - decreased by 2, not 5
    • Performs a deep inequality check between the actual and expected values, throwing an AssertionFailure with the given message when the actual value is deeply equal to the expected value. This method compares the values of all properties of objects and elements of arrays.

      Type Parameters

      • T

        The type of the values.

      Parameters

      • actual: T

        The actual value.

      • expected: T

        The expected value.

      • OptionalinitMsg: MsgSource

        The message to display if actual is deeply equal to expected.

      Returns AssertInst

      That the actual and expected values are not deeply equal and throws AssertionFailure if they are.

      assert.notDeepEqual({ a: 1 }, { a: 2 }); // Passes
      assert.notDeepEqual({ a: 1 }, { a: 1 }); // Throws AssertionFailure
      assert.notDeepEqual([1, 2], [2, 1]); // Passes
      assert.notDeepEqual([1, 2], [1, 2]); // Throws AssertionFailure
      assert.notDeepEqual({ a: { b: 1 } }, { a: { b: 2 } }); // Passes
      assert.notDeepEqual({ a: { b: 1 } }, { a: { b: 1 } }); // Throws AssertionFailure
      assert.notDeepEqual([{ a: 1 }], [{ a: 2 }]); // Passes
      assert.notDeepEqual([{ a: 1 }], [{ a: 1 }]); // Throws AssertionFailure
    • Performs a deep inequality check between the actual and expected values, throwing an AssertionFailure with the given message when the actual value is deeply equal to the expected value. This method compares the values of all properties of objects and elements of arrays.

      Type Parameters

      • T

        The type of the values.

      Parameters

      • actual: T

        The actual value.

      • expected: T

        The expected value.

      • OptionalinitMsg: MsgSource

        The message to display if actual is deeply equal to expected.

      Returns AssertInst

      That the actual and expected values are not deeply equal and throws AssertionFailure if they are.

      notDeepEqual

      assert.notDeepEquals({ a: 1 }, { a: 2 }); // Passes
      assert.notDeepEquals({ a: 1 }, { a: 1 }); // Throws AssertionFailure
      assert.notDeepEquals([1, 2], [2, 1]); // Passes
      assert.notDeepEquals([1, 2], [1, 2]); // Throws AssertionFailure
      assert.notDeepEquals({ a: { b: 1 } }, { a: { b: 2 } }); // Passes
      assert.notDeepEquals({ a: { b: 1 } }, { a: { b: 1 } }); // Throws AssertionFailure
      assert.notDeepEquals([{ a: 1 }], [{ a: 2 }]); // Passes
      assert.notDeepEquals([{ a: 1 }], [{ a: 1 }]); // Throws AssertionFailure
    • Asserts that the value does NOT contain the expected using deep nested property matching.

      Type Parameters

      • T

      Parameters

      • value: T

        The object to search in.

      • expected: any

        The object with properties to match (can use dot notation for keys).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value does not contain the expected using deep nested property matching and throws AssertionFailure if it does.

      0.1.5

      assert.notDeepNestedInclude({ a: { b: { c: { d: 1 } } } }, { 'a.b.c': { d: 2 } }); // Passes
      assert.notDeepNestedInclude({ a: { b: { c: { d: 1 } } } }, { 'a.b.c': { d: 1 } }); // Throws AssertionFailure
    • Asserts that the provided value does NOT have the specified nested property with a value that matches using deep equality.

      Type Parameters

      • T

      Parameters

      • target: T

        The value to evaluate.

      • path: string

        The dot-separated path to the property (e.g., "a.b.c").

      • Optionalvalue: any

        Optional. The value that should NOT match (uses deep equality).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value does not have the specified nested property with matching deep value and throws AssertionFailure if it does.

      0.1.5

      assert.notDeepNestedProperty({ a: { b: { c: { d: 1 } } } }, "a.b.d"); // Passes (property doesn't exist)
      assert.notDeepNestedProperty({ a: { b: { c: { d: 1 } } } }, "a.b.d", { d: 1 }); // Passes (property doesn't exist)
      assert.notDeepNestedProperty({ a: { b: { c: { d: 1 } } } }, "a.b.c", { d: 2 }); // Passes (value doesn't match)
      assert.notDeepNestedProperty({ a: { b: { c: { d: 1 } } } }, "a.b.c", { d: 1 }); // Throws AssertionFailure
    • Asserts that the value does NOT contain the expected using deep own property matching. For objects, checks that not all keys in the expected are own properties (not inherited) or that values don't match using deep equality.

      Type Parameters

      • T

      Parameters

      • value: T

        The object to search in.

      • expected: any

        The value or object with properties to match.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value does not deeply contain the expected using own property matching and throws AssertionFailure if it does.

      0.1.5

      assert.notDeepOwnInclude({ a: { b: 1 } }, { a: { b: 2 } }); // Passes
      assert.notDeepOwnInclude({ a: 1 }, { b: 1 }); // Passes
      assert.notDeepOwnInclude({ a: { b: 1 } }, { a: { b: 1 } }); // Throws AssertionFailure
      // Inherited properties are not matched:
      const obj = Object.create({ inherited: { deep: 1 } });
      obj.own = { deep: 2 };
      assert.notDeepOwnInclude(obj, { inherited: { deep: 1 } }); // Passes
    • Throws an AssertionFailure with the given message if actual is equal to expected.

      Type Parameters

      • T

        The type of the values.

      Parameters

      • actual: T

        The actual value.

      • expected: T

        The expected value.

      • OptionalinitMsg: MsgSource

        The message to display if actual is equal to expected.

      Returns AssertInst

      That the actual and expected values are not loosely (!=) equal and throws AssertionFailure if they are.

      assert.notEqual(1, 1); // Throws AssertionFailure
      assert.notEqual(1, 2); // Passes
      assert.notEqual("a", "a"); // Throws AssertionFailure
      assert.notEqual("a", "b"); // Passes
      assert.notEqual([1, 2], [1, 2]); // Passes
      assert.notEqual([1, 2], [1, 2], "Arrays are equal"); // Throws AssertionFailure
      assert.notEqual({ a: 1 }, { a: 1 }); // Passes
      assert.notEqual({ a: 1 }, { a: 1 }, "Objects are equal"); // Throws AssertionFailure
      assert.notEqual({ a: 1 }, { a: 2 }); // Passes
      assert.notEqual({ a: 1 }, { a: 2 }, "Objects are equal"); // Throws AssertionFailure
      assert.notEqual({ a: 1 }, { b: 1 }); // Passes
      assert.notEqual({ a: 1 }, { b: 1 }, "Objects are equal"); // Throws AssertionFailure
      assert.notEqual({ a: 1 }, { b: 2 }); // Passes
      assert.notEqual({ a: 1 }, { b: 2 }, "Objects are equal"); // Throws AssertionFailure
    • Throws an AssertionFailure with the given message if actual is equal to expected.

      Type Parameters

      • T

        The type of the values.

      Parameters

      • actual: T

        The actual value.

      • expected: T

        The expected value.

      • OptionalinitMsg: MsgSource

        The message to display if actual is equal to expected.

      Returns AssertInst

      That the actual and expected values are not loosely (!=) equal and throws AssertionFailure if they are.

      notEqual

      assert.notEquals(1, 1); // Throws AssertionFailure
      assert.notEquals(1, 2); // Passes
      assert.notEquals("a", "a"); // Throws AssertionFailure
      assert.notEquals("a", "b"); // Passes
      assert.notEquals([1, 2], [1, 2]); // Passes
      assert.notEquals([1, 2], [1, 2], "Arrays are equal"); // Throws AssertionFailure
      assert.notEquals({ a: 1 }, { a: 1 }); // Passes
      assert.notEquals({ a: 1 }, { a: 1 }, "Objects are equal"); // Throws AssertionFailure
      assert.notEquals({ a: 1 }, { a: 2 }); // Passes
      assert.notEquals({ a: 1 }, { a: 2 }, "Objects are equal"); // Throws AssertionFailure
      assert.notEquals({ a: 1 }, { b: 1 }); // Passes
      assert.notEquals({ a: 1 }, { b: 1 }, "Objects are equal"); // Throws AssertionFailure
      assert.notEquals({ a: 1 }, { b: 2 }); // Passes
      assert.notEquals({ a: 1 }, { b: 2 }, "Objects are equal"); // Throws AssertionFailure
    • Asserts that the given value does not exist (is null or undefined).

      Parameters

      • value: any

        The value to check.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      0.1.5

      That the value is null or undefined and throws AssertionFailure if it is not.

      assert.notExists(null); // Passes
      assert.notExists(undefined); // Passes
      assert.notExists(0); // Throws AssertionFailure
      assert.notExists(""); // Throws AssertionFailure
      assert.notExists(false); // Throws AssertionFailure
    • Asserts that the provided value does NOT have the specified own property with a value that matches using deep equality.

      Type Parameters

      • T

      Parameters

      • target: T

        The value to evaluate.

      • name: string

        The name of the own property to check for.

      • value: any

        The value that should NOT match (uses deep equality).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value does not have the specified own property with matching deep value and throws AssertionFailure if it does.

      0.1.5

      assert.notHasDeepOwnProperty({ a: { b: 1 } }, "c", { b: 1 }); // Passes
      assert.notHasDeepOwnProperty({ a: { b: 1 } }, "a", { b: 2 }); // Passes
      assert.notHasDeepOwnProperty({ a: { b: 1 } }, "a", { b: 1 }); // Throws AssertionFailure
    • Asserts that the provided value does NOT have the specified property with a value that matches using deep equality.

      Type Parameters

      • T

      Parameters

      • target: T

        The value to evaluate.

      • name: string

        The name of the property to check for.

      • value: any

        The value that should NOT match (uses deep equality).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value does not have the specified property with matching deep value and throws AssertionFailure if it does.

      0.1.5

      assert.notHasDeepProperty({ a: { b: 1 } }, "c", { b: 2 }); // Passes
      assert.notHasDeepProperty({ a: { b: 1 } }, "a", { b: 2 }); // Passes
      assert.notHasDeepProperty({ a: { b: 1 } }, "a", { b: 1 }); // Throws AssertionFailure
    • Asserts that the provided value does NOT have the specified own property, or if a value is provided, that the own property value does NOT match using loose equality (==).

      Type Parameters

      • T

      Parameters

      • target: T

        The value to evaluate.

      • name: string

        The name of the own property to check for.

      • Optionalvalue: any

        Optional. The value that should NOT match (uses loose equality).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value does not have the specified own property (or value doesn't match) and throws AssertionFailure if it does.

      0.1.5

      assert.notHasOwnProperty({ a: 1 }, "b"); // Passes
      assert.notHasOwnProperty({ a: 1 }, "a"); // Throws AssertionFailure
      assert.notHasOwnProperty({ a: 1 }, "a", 2); // Passes
      assert.notHasOwnProperty({ a: 1 }, "a", 1); // Throws AssertionFailure
    • Asserts that the provided value does NOT have the specified property, or if a value is provided, that the property value does NOT match using loose equality (==).

      Type Parameters

      • T

      Parameters

      • target: T

        The value to evaluate.

      • name: string

        The name of the property to check for.

      • Optionalvalue: any

        Optional. The value that should NOT match (uses loose equality).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value does not have the specified property (or value doesn't match) and throws AssertionFailure if it does.

      0.1.5

      assert.notHasProperty({ a: 1 }, "b"); // Passes
      assert.notHasProperty({ a: 1 }, "a"); // Throws AssertionFailure
      assert.notHasProperty({ a: 1 }, "a", 2); // Passes
      assert.notHasProperty({ a: 1 }, "a", 1); // Throws AssertionFailure
    • Asserts that the target does NOT have all of the specified keys using deep equality comparison. This method checks that at least one of the given keys does not exist in the target using deep equality for key comparison. This is the inverse of hasAllDeepKeys.

      Parameters

      • target: any

        The object, Map, or Set to check for keys.

      • keys: any

        The keys to search for (array, Set, Map, or other iterable of keys, or a single key).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the target does not have all of the specified keys and throws AssertionFailure if it does.

      0.1.5

      const obj = { greeting: "hello", subject: "friend" };
      assert.notHaveAllDeepKeys(obj, "unknown"); // Passes - missing "unknown"
      assert.notHaveAllDeepKeys(obj, ["greeting", "unknown"]); // Passes - missing "unknown"

      const map = new Map([[{ id: 1 }, "value1"]]);
      assert.notHaveAllDeepKeys(map, [{ id: 1 }, { id: 2 }]); // Passes - missing { id: 2 }
      assert.notHaveAllDeepKeys(obj, ["greeting", "subject"]); // Throws AssertionFailure - has both keys
    • Asserts that the target does NOT have any of the specified keys using deep equality comparison. This method checks that none of the given keys exist in the target using deep equality for key comparison. This is the inverse of hasAnyDeepKeys.

      Parameters

      • target: any

        The object, Map, or Set to check for keys.

      • keys: any

        The keys to search for (array, Set, Map, or other iterable of keys, or a single key).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the target does not have any of the specified keys and throws AssertionFailure if it does.

      0.1.5

      const obj = { greeting: "hello", subject: "friend" };
      assert.notHaveAnyDeepKeys(obj, "unknown"); // Passes - does not have the key
      assert.notHaveAnyDeepKeys(obj, ["unknown", "missing"]); // Passes - has neither key

      const map = new Map([[{ id: 1 }, "value1"]]);
      assert.notHaveAnyDeepKeys(map, [{ id: 3 }, { id: 4 }]); // Passes - has neither key
      assert.notHaveAnyDeepKeys(obj, ["greeting", "unknown"]); // Throws AssertionFailure - has "greeting"
    • Asserts that executing the target function increases the monitored value but NOT by the specified delta.

      Parameters

      • fn: () => void

        The function to execute that should increase the value.

      • getter: () => any

        A function that returns the value to monitor.

      • delta: number

        The delta that should NOT match.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      let value = 0;
      const getValue = () => value;
      const addTwo = () => { value += 2; };
      assert.notIncreasesBy(addTwo, getValue, 5); // Passes - increased by 2, not 5
    • Asserts that executing the target function increases the monitored object property but NOT by the specified delta.

      Type Parameters

      • T

      Parameters

      • fn: () => void

        The function to execute that should increase the value.

      • target: T

        An object containing the property to monitor.

      • prop: keyof T

        The property name to monitor.

      • delta: number

        The delta that should NOT match.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      const obj = { count: 10 };
      const addTwo = () => { obj.count += 2; };
      assert.notIncreasesBy(addTwo, obj, 'count', 5); // Passes - increased by 2, not 5
    • Asserts that the target does not have a length or size property equal to the given number.

      Works with arrays, strings, Maps, Sets, and any object with a length or size property. This is the inverse of lengthOf.

      Type Parameters

      • T extends { length?: number } | { size?: number }

      Parameters

      • object: T

        The object to check (array, string, Map, Set, or any object with length/size).

      • length: number

        The length or size that the object should not have.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      0.1.5

      That object does not have a length or size equal to length and throws AssertionFailure if it does.

      assert.notLengthOf([1, 2, 3], 2); // Passes
      assert.notLengthOf("hello", 4); // Passes
      assert.notLengthOf([1, 2], 2); // Throws AssertionFailure
    • Asserts that the provided value does NOT match the specified regular expression. If the value matches the regular expression, it throws an AssertionFailure with the given message. This is the inverse of match.

      Type Parameters

      • T

      Parameters

      • value: T

        The value to evaluate.

      • regexp: RegExp

        The regular expression that should not match.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value does not match the regular expression and throws AssertionFailure if it does.

      0.1.5

      assert.notMatch("hello world", /nomatch/); // Passes
      assert.notMatch("hello world", /goodbye/); // Passes
      assert.notMatch("hello world", /hello/); // Throws AssertionFailure
      assert.notMatch("hello world", /world$/); // Throws AssertionFailure
    • Asserts that the value does NOT contain the expected using nested property matching.

      Type Parameters

      • T

      Parameters

      • value: T

        The object to search in.

      • expected: any

        The object with properties to match (can use dot notation for keys).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value does not contain the expected using nested property matching and throws AssertionFailure if it does.

      0.1.5

      assert.notNestedInclude({ a: { b: { c: 1 } } }, { 'a.b.c': 2 }); // Passes
      assert.notNestedInclude({ a: { b: { c: 1 } } }, { 'a.b.c': 1 }); // Throws AssertionFailure
    • Asserts that the provided value does NOT have the specified nested property using dot notation, or if a value is provided, that the nested property value does NOT match using loose equality (==).

      Type Parameters

      • T

      Parameters

      • target: T

        The value to evaluate.

      • path: string

        The dot-separated path to the property (e.g., "a.b.c").

      • Optionalvalue: any

        Optional. The value that should NOT match (uses loose equality).

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value does not have the specified nested property (or value doesn't match) and throws AssertionFailure if it does.

      0.1.5

      assert.notNestedProperty({ a: { b: 2 } }, "a.b.c"); // Passes
      assert.notNestedProperty({ a: { b: { c: 1 } } }, "a.b.c"); // Throws AssertionFailure
      assert.notNestedProperty({ a: { b: { c: 1 } } }, "a.b.c", 2); // Passes
      assert.notNestedProperty({ a: { b: { c: 1 } } }, "a.b.c", 1); // Throws AssertionFailure
    • Asserts that the value is NOT a member of the given list. Uses strict equality (===) to check if the value is in the list. Supports arrays, array-like objects (with length), Sets, Maps, and other iterables with size. This is the inverse of oneOf.

      Parameters

      • value: any

        The value to check.

      • list: ArrayLikeOrSizedIterable

        The array, array-like, Set, Map, or other iterable of possible values to check against.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      // With arrays
      assert.notOneOf(5, [1, 2, 3]); // Passes
      assert.notOneOf("x", ["a", "b", "c"]); // Passes
      assert.notOneOf(1, [1, 2, 3]); // Throws AssertionFailure
      assert.notOneOf("a", ["a", "b", "c"]); // Throws AssertionFailure

      // With Sets
      const mySet = new Set([1, 2, 3]);
      assert.notOneOf(5, mySet); // Passes
    • Asserts that the value does NOT contain the expected using own property matching. For objects, checks that not all keys in the expected are own properties (not inherited) or that values don't match using strict equality (===).

      Type Parameters

      • T

      Parameters

      • value: T

        The object to search in.

      • expected: any

        The value or object with properties to match.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value does not contain the expected using own property matching and throws AssertionFailure if it does.

      0.1.5

      assert.notOwnInclude({ a: 1 }, { a: 2 }); // Passes
      assert.notOwnInclude({ a: 1 }, { b: 1 }); // Passes
      assert.notOwnInclude({ a: 1 }, { a: 1 }); // Throws AssertionFailure
      // Inherited properties are not matched:
      const obj = Object.create({ inherited: 1 });
      obj.own = 2;
      assert.notOwnInclude(obj, { inherited: 1 }); // Passes
    • Asserts that the actual collection does not have the same members as the expected collection. This is the inverse of sameMembers. Both arguments must conform to ArrayLikeOrSizedIterable but can be different concrete types.

      Type Parameters

      • T

      Parameters

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      assert.notSameMembers([1, 2, 3], [1, 2]);                 // Passes - different length
      assert.notSameMembers([1, 2, 3], [1, 2, 4]); // Passes - different members
      assert.notSameMembers([1, 2, 3], new Set([1, 2, 4])); // Passes - different members
      assert.notSameMembers(new Set([1, 2, 3]), [1, 2, 4]); // Passes - different members
      assert.notSameMembers([1, 2, 3], [3, 2, 1]); // Throws AssertionFailure - same members
      assert.notSameMembers([1, 2, 3], new Set([3, 2, 1])); // Throws AssertionFailure - same members
    • Asserts that the target does not have a size or length property equal to the given number.

      Works with arrays, strings, Maps, Sets, and any object with a length or size property. This is the inverse of sizeOf.

      Type Parameters

      • T extends { length?: number } | { size?: number }

      Parameters

      • object: T

        The object to check (array, string, Map, Set, or any object with length/size).

      • length: number

        The length or size that the object should not have.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      0.1.5

      That object does not have a length or size equal to length and throws AssertionFailure if it does.

      assert.notSizeOf([1, 2, 3], 2); // Passes
      assert.notSizeOf("hello", 4); // Passes
      assert.notSizeOf([1, 2], 2); // Throws AssertionFailure
    • Performs a strict in-equality check (!==) between the actual and expected values, throwing an AssertionFailure with the given message when the actual value is not exactly equal to the expected value. To perform a loose equality check (==), use the assert.equal method.

      Type Parameters

      • T

        The type of the values.

      Parameters

      • actual: T

        The actual value.

      • expected: unknown

        The expected value.

      • OptionalinitMsg: MsgSource

        The message to display if actual is not equal to expected.

      Returns AssertInst

      That the actual and expected values are strictly (===) equal and throws AssertionFailure if they are not.

    • Asserts that the given value's type does not match the expected type string. Uses the JavaScript typeof operator for type comparison.

      Valid type strings include:

      • "string"
      • "number"
      • "bigint"
      • "boolean"
      • "symbol"
      • "undefined"
      • "object" (includes null, arrays, and objects)
      • "null"
      • "array"
      • "function" (includes async, generator, and async generator functions)
      • "asyncfunction"
      • "generatorfunction"
      • "asyncgeneratorfunction"

      Parameters

      • value: any

        The value to check.

      • type: string

        The type string that the value should not match.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value is not of the specified type and throws AssertionFailure if it is.

      0.1.5

      assert.notTypeOf("hello", "number"); // Passes
      assert.notTypeOf(123, "string"); // Passes
      assert.notTypeOf(() => {}, "object"); // Passes
      assert.notTypeOf({}, "function"); // Passes
      assert.notTypeOf("hello", "string"); // Throws AssertionFailure
      assert.notTypeOf(123, "number"); // Throws AssertionFailure
    • Throws an AssertionFailure with the given message if value is not truthy. This method is used to assert that a value is truthy.

      Type Parameters

      • T

        The type of the value.

      Parameters

      • value: T

        The value to evaluate. If the value is not truthy, an AssertionFailure is thrown.

      • OptionalinitMsg: MsgSource

        The message to display if value is not truthy. This can be a string or a function returning a string.

      Returns AssertInst

      That the value is truthy and throws AssertionFailure if it is not.

      assert.ok(1); // Passes
      assert.ok("a"); // Passes
      assert.ok([]); // Passes
      assert.ok({}); // Passes
      assert.ok(new Map()); // Passes
      assert.ok(new Set()); // Passes
      assert.ok(new Date()); // Passes
      assert.ok(true); // Passes
      assert.ok(false); // Throws AssertionFailure
      assert.ok(0, "Value should be truthy"); // Throws AssertionFailure with message "Value should be truthy"
      assert.ok(""); // Throws AssertionFailure
      assert.ok(null); // Throws AssertionFailure
      assert.ok(undefined); // Throws AssertionFailure
    • Asserts that the value is a member of the given list. Uses strict equality (===) to check if the value is in the list. Supports arrays, array-like objects (with length), Sets, Maps, and other iterables with size.

      Parameters

      • value: any

        The value to check.

      • list: ArrayLikeOrSizedIterable

        The array, array-like, Set, Map, or other iterable of possible values to check against.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      // With arrays
      assert.oneOf(1, [1, 2, 3]); // Passes
      assert.oneOf("a", ["a", "b", "c"]); // Passes
      assert.oneOf(true, [true, false]); // Passes
      assert.oneOf(5, [1, 2, 3]); // Throws AssertionFailure
      assert.oneOf("x", ["a", "b", "c"]); // Throws AssertionFailure

      // With Sets
      const mySet = new Set([1, 2, 3]);
      assert.oneOf(2, mySet); // Passes
    • Asserts that value is compared to expected using the given operator and the result is true. Supports comparison operators: ==, ===, <, >, <=, >=, !=, !==, typeof The support for typeof is in the form of typeof XXX === "expected", where expected is the type name string.

      Parameters

      • value: any

        The first value to compare.

      • operator: string

        The comparison operator to use.

      • expected: any

        The second value to compare.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      assert.operator(1, "<", 2);      // Passes
      assert.operator(2, ">", 1); // Passes
      assert.operator(1, "==", 1); // Passes
      assert.operator(1, "===", 1); // Passes
      assert.operator(1, "<=", 1); // Passes
      assert.operator(1, ">=", 1); // Passes
      assert.operator(1, "!=", 2); // Passes
      assert.operator(1, "!==", 2); // Passes
      assert.operator(1, "!==", "1"); // Passes - type difference
      assert.operator(2, "<", 1); // Throws AssertionFailure
      assert.operator(1, "=", 2); // Throws AssertionFailure - invalid operator

      // Typeof operator
      assert.operator("hello", "typeof", "string"); // Passes - simplistic type check
      assert.operator(123, "typeof", "number"); // Passes
      assert.operator(true, "typeof", "boolean"); // Passes
      assert.operator(123, "typeof", "string"); // Throws AssertionFailure
    • Asserts that the value contains the expected using own property matching only. For objects, checks that all keys in the expected are own properties (not inherited) and that values match using strict equality (===).

      Type Parameters

      • T

      Parameters

      • value: T

        The object to search in.

      • expected: any

        The value or object with properties to match.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value contains the expected using own property matching and throws AssertionFailure if it does not.

      0.1.5

      assert.ownInclude({ a: 1, b: 2 }, { a: 1 }); // Passes
      assert.ownInclude({ a: 1, b: 2 }, { a: 1, b: 2 }); // Passes
      assert.ownInclude({ a: 1 }, { a: 2 }); // Throws AssertionFailure
      // Inherited properties are not matched:
      const obj = Object.create({ inherited: 1 });
      obj.own = 2;
      assert.ownInclude(obj, { own: 2 }); // Passes
      assert.ownInclude(obj, { inherited: 1 }); // Throws AssertionFailure
    • Asserts that the actual collection has the same members as the expected collection, regardless of order. Uses deep equality for comparison. Particularly useful for Maps which iterate over [key, value] pairs. Both arguments must conform to ArrayLikeOrSizedIterable but can be different concrete types.

      Type Parameters

      • T

      Parameters

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      assert.sameDeepMembers([{a: 1}, {b: 2}], [{b: 2}, {a: 1}]);      // Passes
      assert.sameDeepMembers([[1, 2], [3, 4]], [[3, 4], [1, 2]]); // Passes
      assert.sameDeepMembers([{a: 1}], new Set([{a: 1}])); // Passes - Array vs Set
      assert.sameDeepMembers(new Set([{a: 1}, {b: 2}]), [{b: 2}, {a: 1}]); // Passes

      // Maps iterate over [key, value] pairs, so use deep comparison
      const map = new Map([[1, "a"], [2, "b"]]);
      assert.sameDeepMembers(map, [[1, "a"], [2, "b"]]); // Passes
      assert.sameDeepMembers([{a: 1}], [{a: 2}]); // Throws AssertionFailure
    • Asserts that the actual collection has the same members as the expected collection, regardless of order. Uses strict equality (===) for comparison. Both arguments must conform to ArrayLikeOrSizedIterable but can be different concrete types.

      Type Parameters

      • T

      Parameters

      Returns AssertInst

      • An assert instance for further chaining.

      0.1.5

      assert.sameMembers([1, 2, 3], [3, 2, 1]);                // Passes - same members, different order
      assert.sameMembers([1, 2, 2, 3], [3, 2, 2, 1]); // Passes - duplicates handled
      assert.sameMembers([1, 2, 3], new Set([3, 2, 1])); // Passes - Array vs Set
      assert.sameMembers(new Set([1, 2, 3]), [3, 2, 1]); // Passes - Set vs Array
      assert.sameMembers(new Set([1, 2, 3]), new Set([3, 2, 1])); // Passes - Set vs Set
      assert.sameMembers([1, 2, 3], [1, 2]); // Throws AssertionFailure - different length
      assert.sameMembers([1, 2, 3], [1, 2, 4]); // Throws AssertionFailure - different members
    • Asserts that the target has a size or length property equal to the given number.

      Works with arrays, strings, Maps, Sets, and any object with a length or size property.

      Type Parameters

      • T extends { length?: number } | { size?: number }

      Parameters

      • object: T

        The object to check (array, string, Map, Set, or any object with length/size).

      • length: number

        The expected length or size.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      0.1.5

      That object has a length or size equal to length and throws AssertionFailure if it does not.

      assert.sizeOf([1, 2, 3], 3); // Passes
      assert.sizeOf("hello", 5); // Passes
      assert.sizeOf(new Map([["a", 1]]), 1); // Passes
      assert.sizeOf(new Set([1, 2]), 2); // Passes
      assert.sizeOf([1, 2], 3); // Throws AssertionFailure
    • Performs a strict equality check (===) between the actual and expected values, throwing an AssertionFailure with the given message when the actual value is not exactly equal to the expected value. To perform a loose equality check (==), use the assert.equal method.

      Type Parameters

      • T

        The type of the values.

      Parameters

      • actual: T

        The actual value.

      • expected: unknown

        The expected value.

      • OptionalinitMsg: MsgSource

        The message to display if actual is not equal to expected.

      Returns AssertInst

      That the actual and expected values are strictly (===) equal and throws AssertionFailure if they are not.

      assert.strictEqual(1, 1); // Passes
      assert.strictEqual(1, "1"); // Throws AssertionFailure
      assert.strictEqual(1, 2); // Throws AssertionFailure
      assert.strictEqual("a", "a"); // Passes
      assert.strictEqual("a", "b"); // Throws AssertionFailure
      assert.strictEqual([1, 2], [1, 2]); // Throws AssertionFailure
      assert.strictEqual([1, 2], [1, 2], "Arrays are not equal"); // Throws AssertionFailure
      assert.strictEqual({ a: 1 }, { a: 1 }); // Throws AssertionFailure
      assert.strictEqual({ a: 1 }, { a: 1 }, "Objects are not equal"); // Throws AssertionFailure
      assert.strictEqual({ a: 1 }, { a: 2 }); // Throws AssertionFailure
      assert.strictEqual({ a: 1 }, { a: 2 }, "Objects are not equal"); // Throws AssertionFailure
      assert.strictEqual({ a: 1 }, { b: 1 }); // Throws AssertionFailure
      assert.strictEqual({ a: 1 }, { b: 1 }, "Objects are not equal"); // Throws AssertionFailure
      assert.strictEqual({ a: 1 }, { b: 2 }); // Throws AssertionFailure
      assert.strictEqual({ a: 1 }, { b: 2 }, "Objects are not equal"); // Throws AssertionFailure
    • Performs a strict equality check (===) between the actual and expected values, throwing an AssertionFailure with the given message when the actual value is not exactly equal to the expected value. To perform a loose equality check (==), use the assert.equal method.

      Type Parameters

      • T

        The type of the values.

      Parameters

      • actual: T

        The actual value.

      • expected: unknown

        The expected value.

      • OptionalinitMsg: MsgSource

        The message to display if actual is not equal to expected.

      Returns AssertInst

      That the actual and expected values are strictly (!==) equal and throws AssertionFailure if they are not.

      strictEqual

    • Asserts that the given function throws an error that matches the specified error constructor, error instance, and / or the message includes the content or matches the regex pattern. If the function does not throw an error, or if the thrown error does not match the specified criteria, it throws an AssertionFailure with the given message. Both the errorLike and msgMatch parameters are optional, so this method can be used to assert that the function throws an error without checking the error type or message.

      Parameters

      • fn: () => void

        The function to execute and check for thrown errors.

      • OptionalerrorLike: Error | ErrorConstructor

        The error constructor, error instance, or message pattern to check against.

      • OptionalmsgMatch: string | RegExp

        The partial message or pattern to check against the error message.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the function throws an error that matches the specified criteria and throws AssertionFailure if it does not.

      assert.throws(() => { throw new Error("test"); }); // Passes
      assert.throws(() => { throw new TypeError("test"); }, TypeError); // Passes
      assert.throws(() => { throw new Error("test"); }, /test/); // Passes
      assert.throws(() => { throw new Error("test"); }, Error, "test"); // Passes
      assert.throws(() => {}); // Throws AssertionFailure
      assert.throws(() => { throw new Error("test"); }, TypeError); // Throws AssertionFailure
      assert.throws(() => { throw new Error("test"); }, /nomatch/); // Throws AssertionFailure
    • Asserts that the given function throws an error and that the message contains the content or matches the regex pattern. If the function does not throw an error, or if the thrown error does not match the specified criteria, it throws an AssertionFailure with the given message. The msgMatch parameter is optional, so this method can be used to assert that the function throws an error without checking the error type or message.

      Parameters

      • fn: () => void

        The function to execute and check for thrown errors.

      • OptionalmsgMatch: string | RegExp

        The partial message or pattern to check against the error message.

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the function throws an error that matches the specified criteria and throws AssertionFailure if it does not.

      assert.throws(() => { throw new Error("test"); }); // Passes
      assert.throws(() => { throw new TypeError("test"); }, TypeError); // Passes
      assert.throws(() => { throw new Error("test"); }, /test/); // Passes
      assert.throws(() => { throw new Error("test"); }, Error, "test"); // Passes
      assert.throws(() => {}); // Throws AssertionFailure
      assert.throws(() => { throw new Error("test"); }, TypeError); // Throws AssertionFailure
      assert.throws(() => { throw new Error("test"); }, /nomatch/); // Throws AssertionFailure
    • Asserts that the given value's type matches the expected type string. Uses the JavaScript typeof operator for type comparison.

      Valid type strings include:

      • "string"
      • "number"
      • "bigint"
      • "boolean"
      • "symbol"
      • "undefined"
      • "object" (includes null, arrays, and objects)
      • "null"
      • "array"
      • "function" (includes async, generator, and async generator functions)
      • "asyncfunction"
      • "generatorfunction"
      • "asyncgeneratorfunction"

      Parameters

      • value: any

        The value to check.

      • type: string

        The expected type string (e.g., "string", "number", "function").

      • OptionalinitMsg: MsgSource

        The message to display if the assertion fails.

      Returns AssertInst

      That the value is of the specified type and throws AssertionFailure if it is not.

      0.1.5

      assert.typeOf("hello", "string"); // Passes
      assert.typeOf(123, "number"); // Passes
      assert.typeOf(() => {}, "function"); // Passes
      assert.typeOf({}, "object"); // Passes
      assert.typeOf(true, "boolean"); // Passes
      assert.typeOf(Symbol(), "symbol"); // Passes
      assert.typeOf(BigInt(123), "bigint"); // Passes
      assert.typeOf(undefined, "undefined"); // Passes
      assert.typeOf("hello", "number"); // Throws AssertionFailure
      assert.typeOf(123, "string"); // Throws AssertionFailure