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

x/unitest/matcher/to_contain_any_keys.ts>toContainAnyKeys

๐Ÿƒ Deno-first universal unit testing framework
Latest
function toContainAnyKeys
import { toContainAnyKeys } from "https://deno.land/x/unitest@v1.0.0-beta.82/matcher/to_contain_any_keys.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[]

Returns

MatchResult