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

x/unitest/matcher/to_have_returned_with.ts>toHaveReturnedWith

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

Use .toHaveReturnedWith to ensure that a mock object returned a specific value

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

test("passes when mock object returned specific value", () => {
  const mockObject = fn((a: number, b: number) => a + b);
  mockObject(1, 2);
  mockObject(3, 4);

  expect(mockObject).toHaveReturnedWith(7);
  expect(mockObject).toHaveReturnedWith(3);
});

Parameters

unnamed 0: MockObject
expected: unknown