Skip to main content
Module

x/unitest/mod.ts>toIncludeSameMembers

🃏 Deno-first universal unit testing framework
Latest
function toIncludeSameMembers
Re-export
import { toIncludeSameMembers } from "https://deno.land/x/unitest@v1.0.0-beta.82/mod.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[]