Skip to main content
Module

x/unitest/mod.ts>toContainAnyKeys

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

Use .toContainAnyKeys when checking if an object contains at least one of the provided keys

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

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

test("passes when object contains at least one matching key", () => {
  const object = { a: "hello", b: "world" };
  expect(object).toContainAnyKeys(["a"]);
  expect(object).toContainAnyKeys(["b", "c"]);
  expect(object).not.toContainAnyKeys(["c"]);
});

Parameters

actual: object
expected: PropertyKey[]