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

x/unitest/matcher/to_include_same_members.ts>toIncludeSameMembers

๐Ÿƒ Deno-first universal unit testing framework
Latest
function toIncludeSameMembers
import { toIncludeSameMembers } from "https://deno.land/x/unitest@v1.0.0-beta.82/matcher/to_include_same_members.ts";

Use .toIncludeSameMembers when checking if two arrays contain equal values, in any order

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

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

test("passes when arrays match in a different order", () => {
  expect([1, 2, 3]).toIncludeSameMembers([3, 1, 2]);
  expect([{ foo: "bar" }, { baz: "qux" }]).toIncludeSameMembers([
    { baz: "qux" },
    { foo: "bar" },
  ]);
});

Parameters

actual: readonly unknown[]
expected: readonly unknown[]