Function assertArrayIncludes

  • 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.

    Type Parameters

    • T

      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.

    • Optionalmsg: string

      The optional message to display if the assertion fails.

    Returns void

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

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