Node.js assert tracker.verify() Function
The tracker.verify() method is used to verify the how many times function was actually called compared to expected number of calls. This function will throw an error if the actual and expected number of calls are not the same.
Syntax:
tracker.verify()
Parameters: This function does not accepts any parameter.
Return Value: It returns void.
Below examplesillustrate the assert tracker.verify() function in nodejs.
Example 1:
Javascript
const assert = require( 'assert' );
const tracker = new assert.CallTracker();
function func() {}
const callsfunc = tracker.calls(func, 2);
callsfunc();
console.log(tracker.verify());
|
Output:
Example 2:
Javascript
const assert = require( 'assert' );
const tracker = new assert.CallTracker();
function func() {}
const callsfunc = tracker.calls(func, 2);
callsfunc();
callsfunc();
console.log(tracker.verify());
|
Output:
Reference:https://nodejs.org/api/assert.html#assert_tracker_verify
Last Updated :
08 Mar, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...