tracker.verify()
添加于:v14.2.0、v12.19.0
遍历传递给
的函数列表,对于未调用预期次数的函数将引发错误。tracker.calls()
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, 2); callsfunc(); // Will throw an error since callsfunc() was only called once. tracker.verify();
const assert = require('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, 2); callsfunc(); // Will throw an error since callsfunc() was only called once. tracker.verify();
相关用法
- Node.js assert.CallTracker tracker.report()用法及代码示例
- Node.js assert.CallTracker tracker.calls([fn][, exact])用法及代码示例
- 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.verify()。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。