Skip to main content
Deno 2 is finally here 🎉️
Learn more
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
interface ConstructorSpy
import { type ConstructorSpy } from "https://deno.land/std@0.220.1/testing/mock.ts";

A constructor wrapper that records all calls made to it.

Type Parameters

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

Properties

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

The function that is being spied on.

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

Information about calls made to the function or instance method.

restored: boolean

Whether or not the original instance method has been restored.

Methods

new(...args: Args): Self
restore(): void

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