@jakobkg/expect
    Preparing search index...

    Type Alias NumberMatchers

    Matchers for values that are number (not bigint).

    type NumberMatchers = {
        toBeRoughly(expected: number, digits?: number): void;
        toBeNaN(): void;
        toBeInteger(): void;
        toBeFinite(): void;
        toBeWithin(min: number, max: number): void;
    }
    Index
    • Passes if the value is within half a unit of the digits-th decimal place of expected, i.e. if they differ by less than 10 ** -digits / 2. Use this instead of CommonMatchers.toBe for results of floating-point arithmetic.

      Parameters

      • expected: number
      • Optionaldigits: number

        Decimal places to compare. Defaults to 2.

      Returns void

      expect(0.1 + 0.2).toBeRoughly(0.3);
      expect(Math.PI).toBeRoughly(3.14159, 5);
    • Passes if min <= value <= max. Both bounds are inclusive.

      Parameters

      • min: number
      • max: number

      Returns void