Skip to main content

calls

method assert.CallTracker.prototype.calls
Jump to headingCallTracker.prototype.calls(exact?: number): () => void

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);

Parameters Jump to heading

optional
Jump to headingexact: number = 1

Return Type Jump to heading

() => void

A function that wraps fn.

Jump to headingCallTracker.prototype.calls<Func extends (...args: any[]) => any>(
fn?: Func,
exact?: number,
): Func

Type Parameters Jump to heading

Jump to headingFunc extends (...args: any[]) => any

Parameters Jump to heading

optional
Jump to headingexact: number

Return Type Jump to heading

Back to top