Skip to main content
Module

x/rhum/mod.ts>Spy

A test double library
Go to Latest
function Spy
import { Spy } from "https://deno.land/x/rhum@v2.1.0-rc.1/mod.ts";

Create a spy out of a function expression.

Type Parameters

OriginalFunction extends Callable<ReturnValue>
ReturnValue

Parameters

functionExpression: OriginalFunction
  • The function expression to turn into a spy.
optional
returnValue: ReturnValue
  • (Optional) The value the spy should return when called. Defaults to "spy-stubbed".

Returns

The original function expression with spying capabilities.

Create a spy out of an object's method.

Type Parameters

OriginalObject
ReturnValue

Parameters

  • The object containing the method to spy on.
  • The method to spy on.
optional
returnValue: ReturnValue
  • (Optional) The value the spy should return when called. Defaults to "spy-stubbed".

Returns

The original method with spying capabilities.

Create spy out of a class.

Type Parameters

OriginalClass

Parameters

constructorFn: Constructor<OriginalClass>
  • The constructor function of the object to spy on.

Returns

The original object with spying capabilities.