diff --git a/doc/api/assert.md b/doc/api/assert.md index 4958e6dd7df474..34c0e47ecf0b52 100644 --- a/doc/api/assert.md +++ b/doc/api/assert.md @@ -2006,6 +2006,32 @@ 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 snapshot. +* Returns: {Promise} + +reads a 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()` will return a rejected `Promise` +with an [`AssertionError`][]. + +If the snapshot file does not exist, the snapshot is written. + +In case it is needed to force a snapshot update, +use [`--update-assert-snapshot`][]; + +By default, a snapshot is read and written to a file, +using the same name as the main entrypoint with `.snapshot` as the extension. + ## `assert.strictEqual(actual, expected[, message])` + +Force updating snapshot files for [`assert.snapshot()`][] + ### `--use-bundled-ca`, `--use-openssl-ca`