tracker.report()
添加於:v14.2.0、v12.19.0
- 返回: <Array> 個對象,包含有關由
tracker.calls()
- 對象<Object>
數組包含有關未調用預期次數的函數的預期和實際調用次數的信息。
import assert from 'node:assert'; // Creates call tracker. const tracker = new assert.CallTracker(); function func() {} function foo() {} // Returns a function that wraps func() that must be called exact times // before tracker.verify(). const callsfunc = tracker.calls(func, 2); // Returns an array containing information on callsfunc() tracker.report(); // [ // { // message: 'Expected the func function to be executed 2 time(s) but was // executed 0 time(s).', // actual: 0, // expected: 2, // operator: 'func', // stack: stack trace // } // ]
const assert = require('node:assert'); // Creates call tracker. const tracker = new assert.CallTracker(); function func() {} function foo() {} // Returns a function that wraps func() that must be called exact times // before tracker.verify(). const callsfunc = tracker.calls(func, 2); // Returns an array containing information on callsfunc() tracker.report(); // [ // { // message: 'Expected the func function to be executed 2 time(s) but was // executed 0 time(s).', // actual: 0, // expected: 2, // operator: 'func', // stack: stack trace // } // ]
相關用法
- Node.js assert.CallTracker tracker.calls([fn][, exact])用法及代碼示例
- Node.js assert.CallTracker tracker.verify()用法及代碼示例
- Node.js trace_events.createTracing(options)用法及代碼示例
- Node.js tracing.disable()用法及代碼示例
- Node.js trace_events.getEnabledCategories()用法及代碼示例
- Node.js trace_events.createTracing()用法及代碼示例
- Node.js transform._transform(chunk, encoding, callback)用法及代碼示例
- Node.js trim()用法及代碼示例
- Node.js tlsSocket.authorized用法及代碼示例
- Node.js tls.DEFAULT_MAX_VERSION用法及代碼示例
- Node.js timersPromises.setTimeout([delay[, value[, options]]])用法及代碼示例
- Node.js tlsSocket.disableRenegotiation()用法及代碼示例
- Node.js tlsSocket.address()用法及代碼示例
- Node.js tlsSocket.remoteAddress用法及代碼示例
- Node.js tlsSocket.setMaxSendFragment()用法及代碼示例
- Node.js tlsSocket.getProtocol()用法及代碼示例
- Node.js tlsSocket.exportKeyingMaterial()用法及代碼示例
- Node.js tls.DEFAULT_ECDH_CURVE用法及代碼示例
- Node.js tty.WriteStream.hasColors([count][, env])用法及代碼示例
- Node.js tlsSocket.getPeerFinished()用法及代碼示例
- Node.js tlsSocket.getFinished()用法及代碼示例
- Node.js timersPromises.setImmediate([value[, options]])用法及代碼示例
- Node.js text轉speech用法及代碼示例
- Node.js tlsSocket.authorizationError用法及代碼示例
- Node.js tlsSocket.getPeerCertificate()用法及代碼示例
注:本文由純淨天空篩選整理自nodejs.org大神的英文原創作品 tracker.report()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。