Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/testing/mock.ts>spy

The Deno Standard Library
Latest
The Standard Library has been moved to JSR. See the blog post for details.
function spy
import { spy } from "https://deno.land/std@0.224.0/testing/mock.ts";

Wraps a function or instance method with a Spy.

Type Parameters

optional
Self = any
optional
Args extends unknown[] = any[]
optional
Return = undefined

Type Parameters

Self
Args extends unknown[]
Return

Parameters

func: (this: Self, ...args: Args) => Return

Type Parameters

Self
Args extends unknown[]
optional
Return = undefined

Parameters

constructor: new (...args: Args) => Self

Type Parameters

Self
Prop extends keyof Self

Parameters

self: Self
property: Prop

Returns

MethodSpy<Self, GetParametersFromProp<Self, Prop>, GetReturnFromProp<Self, Prop>>