From 1352f08778db2120110e28c35c50294be58b8310 Mon Sep 17 00:00:00 2001 From: Moshe Atlow Date: Sat, 7 Jan 2023 22:24:24 +0200 Subject: [PATCH] assert: remove `assert.snapshot` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/46112 Reviewed-By: Geoffrey Booth Reviewed-By: Antoine du Hamel Reviewed-By: Luigi Pinca Reviewed-By: Tobias Nießen --- doc/api/assert.md | 44 ------ doc/api/cli.md | 10 -- doc/api/errors.md | 7 - doc/node.1 | 3 - lib/assert.js | 3 - lib/internal/assert/snapshot.js | 129 ----------------- lib/internal/errors.js | 2 - src/node_options.cc | 5 - src/node_options.h | 1 - test/fixtures/assert-snapshot/basic.mjs | 3 - test/fixtures/assert-snapshot/multiple.mjs | 4 - .../assert-snapshot/non-existing-name.mjs | 4 - .../non-existing-name.snapshot | 5 - test/fixtures/assert-snapshot/random.mjs | 11 -- test/fixtures/assert-snapshot/random.snapshot | 5 - test/fixtures/assert-snapshot/serialize.mjs | 11 -- .../assert-snapshot/serialize.snapshot | 11 -- test/fixtures/assert-snapshot/single.mjs | 3 - .../assert-snapshot/value-changed.mjs | 3 - .../assert-snapshot/value-changed.snapshot | 2 - test/parallel/test-assert-snapshot.mjs | 133 ------------------ test/parallel/test-runner-run.mjs | 12 +- 22 files changed, 6 insertions(+), 405 deletions(-) delete mode 100644 lib/internal/assert/snapshot.js delete mode 100644 test/fixtures/assert-snapshot/basic.mjs delete mode 100644 test/fixtures/assert-snapshot/multiple.mjs delete mode 100644 test/fixtures/assert-snapshot/non-existing-name.mjs delete mode 100644 test/fixtures/assert-snapshot/non-existing-name.snapshot delete mode 100644 test/fixtures/assert-snapshot/random.mjs delete mode 100644 test/fixtures/assert-snapshot/random.snapshot delete mode 100644 test/fixtures/assert-snapshot/serialize.mjs delete mode 100644 test/fixtures/assert-snapshot/serialize.snapshot delete mode 100644 test/fixtures/assert-snapshot/single.mjs delete mode 100644 test/fixtures/assert-snapshot/value-changed.mjs delete mode 100644 test/fixtures/assert-snapshot/value-changed.snapshot delete mode 100644 test/parallel/test-assert-snapshot.mjs diff --git a/doc/api/assert.md b/doc/api/assert.md index a77dd196e0063b..9a0a65008f066f 100644 --- a/doc/api/assert.md +++ b/doc/api/assert.md @@ -2089,48 +2089,6 @@ argument, then `error` is assumed to be omitted and the string will be used for example in [`assert.throws()`][] carefully if using a string as the second argument gets considered. -## `assert.snapshot(value, name)` - - - -> Stability: 1 - Experimental - -* `value` {any} the value to snapshot. -* `name` {string} the name of the snapshot. -* Returns: {Promise} - -Reads the `name` snapshot from a file and compares `value` to the snapshot. -`value` is serialized with [`util.inspect()`][]. If the value is not strictly -equal to the snapshot, `assert.snapshot()` returns a rejected `Promise` with an -[`AssertionError`][]. - -The snapshot filename uses the same basename as the application's main -entrypoint with a `.snapshot` extension. If the snapshot file does not exist, -it is created. The [`--update-assert-snapshot`][] command line flag can be used -to force the update of an existing snapshot. - -```mjs -import assert from 'node:assert/strict'; - -// Assuming that the application's main entrypoint is app.mjs, this reads the -// 'snapshotName' snapshot from app.snapshot and strictly compares its value -// to `util.inspect('value')`. -await assert.snapshot('value', 'snapshotName'); -``` - -```cjs -const assert = require('node:assert/strict'); - -(async () => { - // Assuming that the application's main entrypoint is app.js, this reads the - // 'snapshotName' snapshot from app.snapshot and strictly compares its value - // to `util.inspect('value')`. - await assert.snapshot('value', 'snapshotName'); -})(); -``` - ## `assert.strictEqual(actual, expected[, message])` - -Updates snapshot files used by [`assert.snapshot()`][]. - ### `--use-bundled-ca`, `--use-openssl-ca`