ConstructorSpy

import { ConstructorSpy } from "jsr:@ende/testing/mock";

interface

interface ConstructorSpy<Self = any, Args extends unknown[] = any[]>

A constructor wrapper that records all calls made to it.

Constructors

constructor

new ConstructorSpy(...args: Args): Self

Construct an instance.

Properties

original

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

The function that is being spied on.

calls

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

Information about calls made to the function or instance method.

restored

restored: boolean

Whether or not the original instance method has been restored.

Methods

restore

restore(): void

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

Source