From 3ad87994ecfa177e19e6719bf0c6549de580623d Mon Sep 17 00:00:00 2001 From: himself65 Date: Thu, 6 Jun 2019 15:12:14 +0800 Subject: [PATCH] doc: add examples at assert.strictEqual PR-URL: https://github.com/nodejs/node/pull/28092 Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell Reviewed-By: Rich Trott --- doc/api/assert.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/api/assert.md b/doc/api/assert.md index 39d93a3d805350..83ab1c9c566a3b 100644 --- a/doc/api/assert.md +++ b/doc/api/assert.md @@ -1065,6 +1065,14 @@ assert.strictEqual('Hello foobar', 'Hello World!'); // + 'Hello foobar' // - 'Hello World!' // ^ + +const apples = 1; +const oranges = 2; +assert.strictEqual(apples, oranges, `apples ${apples} !== oranges ${oranges}`); +// AssertionError [ERR_ASSERTION]: apples 1 !== oranges 2 + +assert.strictEqual(1, '1', new TypeError('Inputs are not identical')); +// TypeError: Inputs are not identical ``` If the values are not strictly equal, an `AssertionError` is thrown with a