Skip to main content

@std/assert@1.0.11
Built and signed on GitHub Actions

Common assertion functions, especially useful for testing

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
4 weeks ago (1.0.11)
function assertArrayIncludes
assertArrayIncludes<T>(
actual: ArrayLikeArg<T>,
expected: ArrayLikeArg<T>,
msg?: string,
): void

Make an assertion that actual includes the expected values. If not then an error will be thrown.

Type parameter can be specified to ensure values under comparison have the same type.

Examples

Usage

import { assertArrayIncludes } from "@std/assert";

assertArrayIncludes([1, 2], [2]); // Doesn't throw
assertArrayIncludes([1, 2], [3]); // Throws

Type Parameters

The type of the elements in the array to compare.

Parameters

actual: ArrayLikeArg<T>

The array-like object to check for.

expected: ArrayLikeArg<T>

The array-like object to check for.

optional
msg: string

The optional message to display if the assertion fails.

Return Type

void

Add Package

deno add jsr:@std/assert

Import symbol

import { assertArrayIncludes } from "@std/assert/array-includes";

---- OR ----

Import directly with a jsr specifier

import { assertArrayIncludes } from "jsr:@std/assert/array-includes";

Add Package

npx jsr add @std/assert

Import symbol

import { assertArrayIncludes } from "@std/assert/array-includes";

Add Package

yarn dlx jsr add @std/assert

Import symbol

import { assertArrayIncludes } from "@std/assert/array-includes";

Add Package

pnpm dlx jsr add @std/assert

Import symbol

import { assertArrayIncludes } from "@std/assert/array-includes";

Add Package

bunx jsr add @std/assert

Import symbol

import { assertArrayIncludes } from "@std/assert/array-includes";