From bf919e0e58238271e1a4eb7601594cacfde11395 Mon Sep 17 00:00:00 2001 From: Moshe Atlow Date: Thu, 5 Jan 2023 21:53:53 +0200 Subject: [PATCH] assert: remove `assert.snapshot` --- 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 d636c70001a5bc..d90dd1577b7cd8 100644 --- a/doc/api/assert.md +++ b/doc/api/assert.md @@ -2093,48 +2093,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`