From 7d43bc6ef3330fc77a6762d0efc07137b5dfb610 Mon Sep 17 00:00:00 2001 From: Moshe Atlow Date: Thu, 27 Apr 2023 09:47:22 +0300 Subject: [PATCH] assert: deprecate callTracker --- doc/api/assert.md | 12 ++++++++++-- doc/api/deprecations.md | 17 +++++++++++++++++ lib/assert.js | 4 ++-- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/doc/api/assert.md b/doc/api/assert.md index 1467d633c25ffd..cae672c3de45e6 100644 --- a/doc/api/assert.md +++ b/doc/api/assert.md @@ -221,11 +221,18 @@ try { added: - v14.2.0 - v12.19.0 +changes: + - version: REPLACEME + pr-url: https://github.com/nodejs/node/pull/47740 + description: the `assert.CallTracker` class has been deprecated and will be + removed in a future version. --> -> Stability: 1 - Experimental +> Stability: 0 - Deprecated -This feature is currently experimental and behavior might still change. +This feature is deprecated and will be removed in a future version. +Please consider usigng other alternatives such as the +[`mock`][] helper function. ### `new assert.CallTracker()` @@ -2559,6 +2566,7 @@ argument. [`assert.strictEqual()`]: #assertstrictequalactual-expected-message [`assert.throws()`]: #assertthrowsfn-error-message [`getColorDepth()`]: tty.md#writestreamgetcolordepthenv +[`mock`]: test.md#mocking [`process.on('exit')`]: process.md#event-exit [`tracker.calls()`]: #trackercallsfn-exact [`tracker.verify()`]: #trackerverify diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 47082e696b6cc9..e1ac0d882663d7 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -3363,6 +3363,21 @@ Type: Runtime In a future version of Node.js, the `asyncResource` property will no longer be added when a function is bound to an `AsyncResource`. +### DEP0173: the `assert.CallTracker` class + + + +Type: Documentation-only + +In a future version of Node.js, [`assert.CallTracker`][], +will be removed. +consider usigng other alternatives such as the [`mock`][] helper function. + [NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf [RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3 [RFC 8247 Section 2.4]: https://www.rfc-editor.org/rfc/rfc8247#section-2.4 @@ -3386,6 +3401,7 @@ be added when a function is bound to an `AsyncResource`. [`Server.listen({fd: })`]: net.md#serverlistenhandle-backlog-callback [`SlowBuffer`]: buffer.md#class-slowbuffer [`WriteStream.open()`]: fs.md#class-fswritestream +[`assert.CallTracker`]: assert.md#class-assertcalltracker [`assert`]: assert.md [`asyncResource.runInAsyncScope()`]: async_context.md#asyncresourceruninasyncscopefn-thisarg-args [`buffer.subarray`]: buffer.md#bufsubarraystart-end @@ -3443,6 +3459,7 @@ be added when a function is bound to an `AsyncResource`. [`message.socket`]: http.md#messagesocket [`message.trailersDistinct`]: http.md#messagetrailersdistinct [`message.trailers`]: http.md#messagetrailers +[`mock`]: test.md#mocking [`module.createRequire()`]: module.md#modulecreaterequirefilename [`os.networkInterfaces()`]: os.md#osnetworkinterfaces [`os.tmpdir()`]: os.md#ostmpdir diff --git a/lib/assert.js b/lib/assert.js index c73e750e337fcb..ddb1a94605d255 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -66,7 +66,7 @@ const { inspect } = require('internal/util/inspect'); const { isPromise, isRegExp } = require('internal/util/types'); const { EOL } = require('internal/constants'); const { BuiltinModule } = require('internal/bootstrap/realm'); -const { isError } = require('internal/util'); +const { isError, deprecate } = require('internal/util'); const errorCache = new SafeMap(); const CallTracker = require('internal/assert/calltracker'); @@ -1049,7 +1049,7 @@ assert.doesNotMatch = function doesNotMatch(string, regexp, message) { internalMatch(string, regexp, message, doesNotMatch); }; -assert.CallTracker = CallTracker; +assert.CallTracker = deprecate(CallTracker, 'assert.CallTracker is deprecated. ', 'DEP0173'); /** * Expose a strict only variant of assert.