Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/unitest/matcher/mod.ts>toSatisfyAny

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

Use .toSatisfyAny when you want to use a custom matcher by supplying a predicate function that returns true for any matching value in an array

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

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

test("passes when any value in array pass given predicate", () => {
  const isOdd = (el: unknown) => typeof el === "number" && el % 2 === 1;
  expect([2, 3, 6, 8]).toSatisfyAny(isOdd);
  expect([2, 4, 8, 12]).not.toSatisfyAny(isOdd);
});

Parameters

actual: T[]
predicate: (value: T) => boolean