@8hobbies/test-utils
    Preparing search index...

    Function expectToBeNonNull

    • Equivalent to calling vitest.expect(arg).not.toBeNull() while also asserting arg to non-null.

      Type Parameters

      • T

        The type of arg.

      Parameters

      • arg: T

        The variable to be asserted.

      Returns asserts arg is Exclude<T, null>

      undefined.

      arg is not null.

      const iAmNotNull: number | null = Math.random() < 1 ? 10 : null;
      expectToBeDefined(iAmNotNull);
      expect(iAmNotNull + 1).toBe(11);