Skip to main content
Module

x/unitest/mod.ts>toBeWithin

🃏 Deno-first universal unit testing framework
Latest
function toBeWithin
Re-export
import { toBeWithin } from "https://deno.land/x/unitest@v1.0.0-beta.82/mod.ts";

Use .toBeWithin when checking if a number is in between the given bounds of: start (inclusive) and end (exclusive)

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

const expect = defineExpect({
  matcherMap: {
    toBeWithin,
  },
  modifierMap: {
    not,
  },
});

test("passes when number is within given bounds", () => {
  expect(1).toBeWithin(1, 3);
  expect(2).toBeWithin(1, 3);
  expect(3).not.toBeWithin(1, 3);
});

Parameters

actual: number
start: number
end: number