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

std/testing/mock.ts>Spy

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
interface Spy
import { type Spy } from "https://deno.land/std@0.199.0/testing/mock.ts";

A function or instance method wrapper that records all calls made to it.

Type Parameters

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

Call Signatures

(this: Self, ...args: Args): Return

Properties

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

The function that is being spied on.

calls: SpyCall<Self, Args, Return>[]

Information about calls made to the function or instance method.

restored: boolean

Whether or not the original instance method has been restored.

Methods

restore(): void

If spying on an instance method, this restores the original instance method.