assertSpyCalls

import { assertSpyCalls } from "jsr:@ende/testing/mock";

function

function assertSpyCalls<Self, Args extends unknown[], Return>(spy: SpyLike<Self, Args, Return>, expectedCalls: number): void

Asserts that a spy is called as much as expected and no more.

spy: SpyLike<Self, Args, Return>

The spy to check

expectedCalls: number

The number of the expected calls.

Example: Usage

import { assertSpyCalls, spy } from "@ende/testing/mock";

const func = spy();

func();
func();

assertSpyCalls(func, 2);

Source