Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/unitest/matcher/mod.ts>toHaveNthReturnedWith

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

Use .toHaveNthReturnedWith to test the specific value that a mock object returned for the nth call

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

test("passes when mock object of last returned with", () => {
  const mockObject = fn((a: number, b: number) => a + b);
  mockObject(1, 2);
  mockObject(3, 4);
  expect(mockObject).toHaveNthReturnedWith(1, 3);
  expect(mockObject).toHaveNthReturnedWith(2, 7);
});

Parameters

unnamed 0: MockObject
nthCall: number
expected: unknown