Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
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]