Skip to main content
Deno 2 is finally here ๐ŸŽ‰๏ธ
Learn more
Module

x/unitest/matcher/to_be_close_to.ts>toBeCloseTo

๐Ÿƒ Deno-first universal unit testing framework
Latest
function toBeCloseTo
import { toBeCloseTo } from "https://deno.land/x/unitest@v1.0.0-beta.82/matcher/to_be_close_to.ts";

Use .toBeCloseTo to compare floating point numbers for approximate equality

import { expect, test } from "https://deno.land/x/unitest@$VERSION/mod.ts";

test("adding works sanely with decimals", () => {
  expect(0.2 + 0.1).toBeCloseTo(0.3, 5);
});

Parameters

actual: number
expected: number
optional
precision = [UNSUPPORTED]