Skip to content
Related Articles

Related Articles

Node.js assert tracker.report() Function
  • Last Updated : 17 Mar, 2021

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 trace.

Syntax:  

tracker.report()

Parameters: This function takes no parameters

Return Value: It returns an object containing complete details of expected and actual number of calls with a stack trace.



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);
  
console.log(tracker.report());

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
callsfunc();
  
console.log(tracker.report());

Output:


Reference:https://nodejs.org/api/assert.html#assert_tracker_report

My Personal Notes arrow_drop_up
Recommended Articles
Page :