diff options
author | himself65 <himself65@outlook.com> | 2019-06-06 15:12:14 +0800 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-07-17 21:13:48 -0700 |
commit | 3ad87994ecfa177e19e6719bf0c6549de580623d (patch) | |
tree | 14ae783156ee25a4cc3a744b9f73ccb694af18cd /doc/api/assert.md | |
parent | 7e977d7cd41cd57ce6bc6b7b639e88377d725cf3 (diff) | |
download | android-node-v8-3ad87994ecfa177e19e6719bf0c6549de580623d.tar.gz android-node-v8-3ad87994ecfa177e19e6719bf0c6549de580623d.tar.bz2 android-node-v8-3ad87994ecfa177e19e6719bf0c6549de580623d.zip |
doc: add examples at assert.strictEqual
PR-URL: https://github.com/nodejs/node/pull/28092
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'doc/api/assert.md')
-rw-r--r-- | doc/api/assert.md | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/doc/api/assert.md b/doc/api/assert.md index 39d93a3d80..83ab1c9c56 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 |