Function assertSpyCall

  • Asserts that a spy is called as expected.

    Type Parameters

    • Self

      The self type of the spy function.

    • Args extends unknown[]

      The arguments type of the spy function.

    • Return

      The return type of the spy function.

    Parameters

    Returns void

    import { assertSpyCall, spy } from "@std/testing/mock";

    const func = spy((a: number, b: number) => a + b);

    func(3, 4);
    func(5, 6);

    // asserts each call made to the spy function.
    assertSpyCall(func, 0, { args: [3, 4], returned: 7 });
    assertSpyCall(func, 1, { args: [5, 6], returned: 11 });