Skip to content

assertArrayEquals

Assert that an array equals the expected array, with type narrowing.

Members are compared by value.

Plain objects and nested arrays are compared recursively, and object keys must match exactly.

Dates are compared by the instant they hold.

Class instances and other values are compared using Object.is.

assertArrayIdentical() compares members by identity.

import { assertArrayEquals } from "@kensio/smartass";
const value: unknown = ["admin", "editor"];
assertArrayEquals(value, ["admin", "editor"]);
// value is now narrowed to ["admin", "editor"]

Source file: src/assert/array-equals/array-equals.assert.ts