calls

fun calls(exact: Number = definedExternally): () -> Unit(source)

The wrapper function is expected to be called exactly exact times. If the function has not been called exactly exact times when tracker.verify() is called, then tracker.verify() will throw an error.

import assert from 'node:assert';

// Creates call tracker.
const tracker = new assert.CallTracker();

function func() {}

// Returns a function that wraps func() that must be called exact times
// before tracker.verify().
const callsfunc = tracker.calls(func);

Since

v14.2.0, v12.19.0

Return

A function that wraps fn.

Parameters

exact=1


fun <Func : Function<Any?>> calls(fn: Func = definedExternally, exact: Number = definedExternally): Func(source)