Function restore

  • Restores all mocks registered in the current session that have not already been restored. If an id is provided, it will restore all mocks registered in the session associed with that id that have not already been restored.

    Parameters

    • Optionalid: number

      The id of the session to restore. If not provided, all mocks registered in the current session are restored.

    Returns void

    import { mockSession, restore, stub } from "@std/testing/mock";
    import { assertEquals, assertNotEquals } from "@std/assert";

    const setTimeout = globalThis.setTimeout;

    stub(globalThis, "setTimeout");

    assertNotEquals(globalThis.setTimeout, setTimeout);

    restore();

    assertEquals(globalThis.setTimeout, setTimeout);