Skip to main content
Deno 2 is finally here ๐ŸŽ‰๏ธ
Learn more
Module

x/unitest/matcher/mod.ts>toHaveBeenCalledTimes

๐Ÿƒ Deno-first universal unit testing framework
Latest
function toHaveBeenCalledTimes
Re-export
import { toHaveBeenCalledTimes } from "https://deno.land/x/unitest@v1.0.0-beta.82/matcher/mod.ts";

Use .toHaveBeenCalledTimes to ensure that a mock object got called exact number of times

import { expect, fn, test } from "https://deno.land/x/unitest@$VERSION/mod.ts";

test("passes when mock object called 2 times", () => {
  const mockObject = fn();
  mockObject();
  mockObject();
  expect(mockObject).toHaveBeenCalledTimes(2);
});

Parameters

unnamed 0: MockObject
expected: number