Skip to main content

@std/testing@0.215.0

latest
Works with
It is unknown whether this package works with Browsers, Deno, Node.js, Cloudflare Workers, Bun
It is unknown whether this package works with Browsers
It is unknown whether this package works with Deno
It is unknown whether this package works with Node.js
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Bun
JSR Score52%
Published2 years ago (0.215.0)
function spy
spy<
Self = any,
Args extends unknown[] = any[],
Return = undefined
>
(): Spy<Self, Args, Return>

Wraps a function or instance method with a Spy.

Type Parameters

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

Return Type

spy<Self, Args extends unknown[], Return>(func: (
this: Self,
...args: Args
) => Return
): Spy<Self, Args, Return>

Type Parameters

Args extends unknown[]
Return

Parameters

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

Return Type

spy<Self, Args extends unknown[], Return = undefined>(constructor: new (...args: Args) => Self): ConstructorSpy<Self, Args>

Type Parameters

Args extends unknown[]
Return = undefined

Parameters

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

Return Type

spy<Self, Prop extends keyof Self>(
self: Self,
property: Prop
): Spy<
Self,
GetReturnFromProp<Self, Prop>
>

Type Parameters

Prop extends keyof Self

Parameters

Return Type

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/testing

Import symbol

import { spy } from "@std/testing/mock";
or

Import directly with a jsr specifier

import { spy } from "jsr:@std/testing/mock";