Function assertSnapshot

  • Make an assertion that actual matches a snapshot. If the snapshot and actual do not match, then throw.

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

    Type Parameters

    • T

      The type of the snapshot

    Parameters

    • context: TestContext

      The test context

    • actual: T

      The actual value to compare

    • options: SnapshotOptions<T>

      The options

    Returns Promise<void>

    import { assertSnapshot } from "@std/testing/snapshot";

    Deno.test("snapshot", async (t) => {
    await assertSnapshot<number>(t, 2);
    });
  • Make an assertion that actual matches a snapshot. If the snapshot and actual do not match, then throw.

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

    Type Parameters

    • T

      The type of the snapshot

    Parameters

    • context: TestContext

      The test context

    • actual: T

      The actual value to compare

    • Optionalmessage: string

      The optional assertion message

    Returns Promise<void>

    import { assertSnapshot } from "@std/testing/snapshot";

    Deno.test("snapshot", async (t) => {
    await assertSnapshot<number>(t, 2);
    });