Function assertEquals

  • Make an assertion that actual and expected are equal, deeply. If not deeply equal, then throw.

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

    Note: When comparing Blob objects, you should first convert them to Uint8Array using the Blob.bytes() method and then compare their contents.

    Type Parameters

    • T

      The type of the values to compare. This is usually inferred.

    Parameters

    • actual: T

      The actual value to compare.

    • expected: T

      The expected value to compare.

    • Optionalmsg: string

      The optional message to display if the assertion fails.

    Returns void

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

    assertEquals("world", "world"); // Doesn't throw
    assertEquals("hello", "world"); // Throws
    import { assertEquals } from "@std/assert";

    const bytes1 = await new Blob(["foo"]).bytes();
    const bytes2 = await new Blob(["foo"]).bytes();

    assertEquals(bytes1, bytes2);