Skip to content

Commit 5e99598

Browse files
MoLowtargos
authored andcommitted
assert: deprecate callTracker
PR-URL: #47740 Fixes: #47492 Reviewed-By: Erick Wendel <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 253a704 commit 5e99598

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

doc/api/assert.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,18 @@ try {
221221
added:
222222
- v14.2.0
223223
- v12.19.0
224+
changes:
225+
- version: REPLACEME
226+
pr-url: https://github.com/nodejs/node/pull/47740
227+
description: the `assert.CallTracker` class has been deprecated and will be
228+
removed in a future version.
224229
-->
225230

226-
> Stability: 1 - Experimental
231+
> Stability: 0 - Deprecated
227232
228-
This feature is currently experimental and behavior might still change.
233+
This feature is deprecated and will be removed in a future version.
234+
Please consider using alternatives such as the
235+
[`mock`][] helper function.
229236

230237
### `new assert.CallTracker()`
231238

@@ -2559,6 +2566,7 @@ argument.
25592566
[`assert.strictEqual()`]: #assertstrictequalactual-expected-message
25602567
[`assert.throws()`]: #assertthrowsfn-error-message
25612568
[`getColorDepth()`]: tty.md#writestreamgetcolordepthenv
2569+
[`mock`]: test.md#mocking
25622570
[`process.on('exit')`]: process.md#event-exit
25632571
[`tracker.calls()`]: #trackercallsfn-exact
25642572
[`tracker.verify()`]: #trackerverify

doc/api/deprecations.md

+17
Original file line numberDiff line numberDiff line change
@@ -3360,6 +3360,21 @@ Type: Runtime
33603360
In a future version of Node.js, the `asyncResource` property will no longer
33613361
be added when a function is bound to an `AsyncResource`.
33623362

3363+
### DEP0173: the `assert.CallTracker` class
3364+
3365+
<!-- YAML
3366+
changes:
3367+
- version: REPLACEME
3368+
pr-url: https://github.com/nodejs/node/pull/47740
3369+
description: Documentation-only deprecation.
3370+
-->
3371+
3372+
Type: Documentation-only
3373+
3374+
In a future version of Node.js, [`assert.CallTracker`][],
3375+
will be removed.
3376+
Consider using alternatives such as the [`mock`][] helper function.
3377+
33633378
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
33643379
[RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3
33653380
[RFC 8247 Section 2.4]: https://www.rfc-editor.org/rfc/rfc8247#section-2.4
@@ -3383,6 +3398,7 @@ be added when a function is bound to an `AsyncResource`.
33833398
[`Server.listen({fd: <number>})`]: net.md#serverlistenhandle-backlog-callback
33843399
[`SlowBuffer`]: buffer.md#class-slowbuffer
33853400
[`WriteStream.open()`]: fs.md#class-fswritestream
3401+
[`assert.CallTracker`]: assert.md#class-assertcalltracker
33863402
[`assert`]: assert.md
33873403
[`asyncResource.runInAsyncScope()`]: async_context.md#asyncresourceruninasyncscopefn-thisarg-args
33883404
[`buffer.subarray`]: buffer.md#bufsubarraystart-end
@@ -3440,6 +3456,7 @@ be added when a function is bound to an `AsyncResource`.
34403456
[`message.socket`]: http.md#messagesocket
34413457
[`message.trailersDistinct`]: http.md#messagetrailersdistinct
34423458
[`message.trailers`]: http.md#messagetrailers
3459+
[`mock`]: test.md#mocking
34433460
[`module.createRequire()`]: module.md#modulecreaterequirefilename
34443461
[`os.networkInterfaces()`]: os.md#osnetworkinterfaces
34453462
[`os.tmpdir()`]: os.md#ostmpdir

lib/assert.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const { inspect } = require('internal/util/inspect');
6666
const { isPromise, isRegExp } = require('internal/util/types');
6767
const { EOL } = require('internal/constants');
6868
const { BuiltinModule } = require('internal/bootstrap/realm');
69-
const { isError } = require('internal/util');
69+
const { isError, deprecate } = require('internal/util');
7070

7171
const errorCache = new SafeMap();
7272
const CallTracker = require('internal/assert/calltracker');
@@ -1049,7 +1049,7 @@ assert.doesNotMatch = function doesNotMatch(string, regexp, message) {
10491049
internalMatch(string, regexp, message, doesNotMatch);
10501050
};
10511051

1052-
assert.CallTracker = CallTracker;
1052+
assert.CallTracker = deprecate(CallTracker, 'assert.CallTracker is deprecated.', 'DEP0173');
10531053

10541054
/**
10551055
* Expose a strict only variant of assert.

0 commit comments

Comments
 (0)