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

x/mock/mock.ts

Utilities to help mock behavior, spy on function calls, stub methods, and fake time for tests.
Very Popular
Latest
import * as mock from "https://deno.land/x/mock@0.15.2/mock.ts";

Classes

An error related to spying on a function or instance method.

Functions

Creates a session that tracks all mocks created before it's restored. If a callback is provided, it restores all mocks created within it.

Creates an async session that tracks all mocks created before the promise resolves.

Restores all mocks registered in the current session that have not already been restored. If an id is provided, it will restore all mocks registered in the session associed with that id that have not already been restored.

f
spy
deprecated

Wraps a function or instance method with a Spy.

f
stub
deprecated

Replaces an instance method with a Stub.

Interfaces

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

Call information recorded by a spy.

An instance method replacement that records all calls made to it.