Node.js assert tracker.verify() Function Last Updated : 08 Mar, 2021 Comments Improve Suggest changes Like Article Like Report 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'); // 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, 2); // called func through callsfunc only 1 time callsfunc(); console.log(tracker.verify()); Output: Example 2: JavaScript const assert = require('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, 2); // called func through callsfunc only 2 times callsfunc(); callsfunc(); console.log(tracker.verify()); Output: Reference:https://nodejs.org/api/assert.html#assert_tracker_verify Comment More infoAdvertise with us Next Article Node.js assert.ok() Function P pratikraut0000 Follow Improve Article Tags : Web Technologies Node.js NodeJS-function NodeJS-assert Similar Reads Node.js assert tracker.calls() Function The tracker.calls() method is used to keep track of the number of times a function is executed. It returns a wrapper function that should be invoked at exact times. When tracker.verify() is executed, if the method has not been called precisely exact times, tracker.verify() will throw an exception. S 1 min read Node.js assert tracker.report() Function The tracker.report() method is used to get information about the expected and actual number of calls of the functions that have not been called the expected number of times. This function returns a JavaScript object containing complete details of the expected and actual number of calls with a stack 1 min read Node.js assert.ok() Function The assert module provides a set of assertion functions for verifying invariants. The assert.ok() function tests if the value is true or not. If the condition is true it will not produce an output else an assertion error is raised. Syntax:  assert.ok(value[, message]) Parameters: This function acc 2 min read Node.js assert.rejects() Function The assert module provides a set of assertion functions for verifying invariants. The assert.rejects() function awaits the asyncFn promise or if the asyncFn is a function then it immediately calls the function and awaits the returned promise to complete and after that it will then check that the pro 3 min read Node.js assert.strictEqual() Function The assert module provides a set of assertion functions for verifying invariants. The assert.strictEqual() function tests strict equality between the actual and expected parameters. If the condition is true it will not produce an output else an assertion error is raised. Syntax: assert.strictEqual( 3 min read Node.js assert.throws() Function The assert module provides a set of assertion functions for verifying invariants. The assert.throws() is used when the code throws an exception based on specific circumstances, to catch the error object for testing and comparison. Syntax: assert.throws(fn[, error][, message]) Parameters: This functi 2 min read Like