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

x/unitest/mock/spy_on.ts>spyOn

🃏 Deno-first universal unit testing framework
Latest
function spyOn
import { spyOn } from "https://deno.land/x/unitest@v1.0.0-beta.82/mock/spy_on.ts";

tracks calls to object method name This function has a side effect.

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

const video = {
  play() {
    return true;
  },
};

test("plays video", () => {
  const spy = spyOn(video, "play");
  const isPlaying = video.play();

  expect(spy).toHaveBeenCalled();
  expect(isPlaying).toBe(true);
});

Type Parameters

T extends object

Parameters

object: T
key: keyof T