@@ -218,8 +218,9 @@ are also recursively evaluated by the following rules.
218218* [ ` Symbol ` ] [ ] properties are not compared.
219219* [ ` WeakMap ` ] [ ] and [ ` WeakSet ` ] [ ] comparison does not rely on their values.
220220
221- The following example does not throw an ` AssertionError ` because the primitives
222- are considered equal by the [ Abstract Equality Comparison] [ ] ( ` == ` ).
221+ The following example does not throw an [ ` AssertionError ` ] [ ] because the
222+ primitives are considered equal by the [ Abstract Equality Comparison] [ ]
223+ ( ` == ` ).
223224
224225``` js
225226// WARNING: This does not throw an AssertionError!
@@ -264,11 +265,11 @@ assert.deepEqual(obj1, obj4);
264265// AssertionError: { a: { b: 1 } } deepEqual {}
265266```
266267
267- If the values are not equal, an ` AssertionError ` is thrown with a ` message `
268+ If the values are not equal, an [ ` AssertionError ` ] [ ] is thrown with a ` message `
268269property set equal to the value of the ` message ` parameter. If the ` message `
269270parameter is undefined, a default error message is assigned. If the ` message `
270271parameter is an instance of an [ ` Error ` ] [ ] then it will be thrown instead of the
271- ` AssertionError ` .
272+ [ ` AssertionError ` ] [ ] .
272273
273274## ` assert.deepStrictEqual(actual, expected[, message]) `
274275<!-- YAML
@@ -418,7 +419,7 @@ assert.deepStrictEqual(weakMap1, weakMap3);
418419// }
419420```
420421
421- If the values are not equal, an ` AssertionError ` is thrown with a ` message `
422+ If the values are not equal, an [ ` AssertionError ` ] [ ] is thrown with a ` message `
422423property set equal to the value of the ` message ` parameter. If the ` message `
423424parameter is undefined, a default error message is assigned. If the ` message `
424425parameter is an instance of an [ ` Error ` ] [ ] then it will be thrown instead of the
@@ -501,9 +502,9 @@ When `assert.doesNotThrow()` is called, it will immediately call the `fn`
501502function.
502503
503504If an error is thrown and it is the same type as that specified by the ` error `
504- parameter, then an ` AssertionError ` is thrown. If the error is of a different
505- type, or if the ` error ` parameter is undefined, the error is propagated back
506- to the caller.
505+ parameter, then an [ ` AssertionError ` ] [ ] is thrown. If the error is of a
506+ different type, or if the ` error ` parameter is undefined, the error is
507+ propagated back to the caller.
507508
508509If specified, ` error ` can be a [ ` Class ` ] [ ] , [ ` RegExp ` ] [ ] or a validation
509510function. See [ ` assert.throws() ` ] [ ] for more details.
@@ -521,7 +522,7 @@ assert.doesNotThrow(
521522);
522523```
523524
524- However, the following will result in an ` AssertionError ` with the message
525+ However, the following will result in an [ ` AssertionError ` ] [ ] with the message
525526'Got unwanted exception...':
526527
527528<!-- eslint-disable no-restricted-syntax -->
@@ -534,8 +535,8 @@ assert.doesNotThrow(
534535);
535536```
536537
537- If an ` AssertionError ` is thrown and a value is provided for the ` message `
538- parameter, the value of ` message ` will be appended to the ` AssertionError `
538+ If an [ ` AssertionError ` ] [ ] is thrown and a value is provided for the ` message `
539+ parameter, the value of ` message ` will be appended to the [ ` AssertionError ` ] [ ]
539540message:
540541
541542<!-- eslint-disable no-restricted-syntax -->
@@ -584,7 +585,7 @@ assert.equal({ a: { b: 1 } }, { a: { b: 1 } });
584585// AssertionError: { a: { b: 1 } } == { a: { b: 1 } }
585586```
586587
587- If the values are not equal, an ` AssertionError ` is thrown with a ` message `
588+ If the values are not equal, an [ ` AssertionError ` ] [ ] is thrown with a ` message `
588589property set equal to the value of the ` message ` parameter. If the ` message `
589590parameter is undefined, a default error message is assigned. If the ` message `
590591parameter is an instance of an [ ` Error ` ] [ ] then it will be thrown instead of the
@@ -597,9 +598,9 @@ added: v0.1.21
597598
598599* ` message ` {string|Error} ** Default:** ` 'Failed' `
599600
600- Throws an ` AssertionError ` with the provided error message or a default error
601- message. If the ` message ` parameter is an instance of an [ ` Error ` ] [ ] then it
602- will be thrown instead of the ` AssertionError ` .
601+ Throws an [ ` AssertionError ` ] [ ] with the provided error message or a default
602+ error message. If the ` message ` parameter is an instance of an [ ` Error ` ] [ ] then
603+ it will be thrown instead of the [ ` AssertionError ` ] [ ] .
603604
604605``` js
605606const assert = require (' assert' ).strict ;
@@ -687,7 +688,7 @@ changes:
687688 - version: v10.0.0
688689 pr-url: https://github.com/nodejs/node/pull/18247
689690 description: Instead of throwing the original error it is now wrapped into
690- an `AssertionError` that contains the full stack trace.
691+ an [ `AssertionError`][] that contains the full stack trace.
691692 - version: v10.0.0
692693 pr-url: https://github.com/nodejs/node/pull/18247
693694 description: Value may now only be `undefined` or `null`. Before all falsy
@@ -795,11 +796,11 @@ assert.notDeepEqual(obj1, obj4);
795796// OK
796797```
797798
798- If the values are deeply equal, an ` AssertionError ` is thrown with a ` message `
799- property set equal to the value of the ` message ` parameter. If the ` message `
800- parameter is undefined, a default error message is assigned. If the ` message `
801- parameter is an instance of an [ ` Error ` ] [ ] then it will be thrown instead of the
802- ` AssertionError ` .
799+ If the values are deeply equal, an [ ` AssertionError ` ] [ ] is thrown with a
800+ ` message ` property set equal to the value of the ` message ` parameter. If the
801+ ` message ` parameter is undefined, a default error message is assigned. If the
802+ ` message ` parameter is an instance of an [ ` Error ` ] [ ] then it will be thrown
803+ instead of the ` AssertionError ` .
803804
804805## ` assert.notDeepStrictEqual(actual, expected[, message]) `
805806<!-- YAML
@@ -843,11 +844,11 @@ assert.notDeepStrictEqual({ a: 1 }, { a: '1' });
843844// OK
844845```
845846
846- If the values are deeply and strictly equal, an ` AssertionError ` is thrown with
847- a ` message ` property set equal to the value of the ` message ` parameter. If the
848- ` message ` parameter is undefined, a default error message is assigned. If the
849- ` message ` parameter is an instance of an [ ` Error ` ] [ ] then it will be thrown
850- instead of the ` AssertionError ` .
847+ If the values are deeply and strictly equal, an [ ` AssertionError ` ] [ ] is thrown
848+ with a ` message ` property set equal to the value of the ` message ` parameter. If
849+ the ` message ` parameter is undefined, a default error message is assigned. If
850+ the ` message ` parameter is an instance of an [ ` Error ` ] [ ] then it will be thrown
851+ instead of the [ ` AssertionError ` ] [ ] .
851852
852853## ` assert.notEqual(actual, expected[, message]) `
853854<!-- YAML
@@ -882,10 +883,10 @@ assert.notEqual(1, '1');
882883// AssertionError: 1 != '1'
883884```
884885
885- If the values are equal, an ` AssertionError ` is thrown with a ` message ` property
886- set equal to the value of the ` message ` parameter. If the ` message ` parameter is
887- undefined, a default error message is assigned. If the ` message ` parameter is an
888- instance of an [ ` Error ` ] [ ] then it will be thrown instead of the
886+ If the values are equal, an [ ` AssertionError ` ] [ ] is thrown with a ` message `
887+ property set equal to the value of the ` message ` parameter. If the ` message `
888+ parameter is undefined, a default error message is assigned. If the ` message `
889+ parameter is an instance of an [ ` Error ` ] [ ] then it will be thrown instead of the
889890` AssertionError ` .
890891
891892## ` assert.notStrictEqual(actual, expected[, message]) `
@@ -919,11 +920,11 @@ assert.notStrictEqual(1, '1');
919920// OK
920921```
921922
922- If the values are strictly equal, an ` AssertionError ` is thrown with a ` message `
923- property set equal to the value of the ` message ` parameter. If the ` message `
924- parameter is undefined, a default error message is assigned. If the ` message `
925- parameter is an instance of an [ ` Error ` ] [ ] then it will be thrown instead of the
926- ` AssertionError ` .
923+ If the values are strictly equal, an [ ` AssertionError ` ] [ ] is thrown with a
924+ ` message ` property set equal to the value of the ` message ` parameter. If the
925+ ` message ` parameter is undefined, a default error message is assigned. If the
926+ ` message ` parameter is an instance of an [ ` Error ` ] [ ] then it will be thrown
927+ instead of the ` AssertionError ` .
927928
928929## ` assert.ok(value[, message]) `
929930<!-- YAML
@@ -941,7 +942,7 @@ changes:
941942Tests if ` value ` is truthy. It is equivalent to
942943` assert.equal(!!value, true, message) ` .
943944
944- If ` value ` is not truthy, an ` AssertionError ` is thrown with a ` message `
945+ If ` value ` is not truthy, an [ ` AssertionError ` ] [ ] is thrown with a ` message `
945946property set equal to the value of the ` message ` parameter. If the ` message `
946947parameter is ` undefined ` , a default error message is assigned. If the ` message `
947948parameter is an instance of an [ ` Error ` ] [ ] then it will be thrown instead of the
@@ -1020,8 +1021,8 @@ an object where each property will be tested for, or an instance of error where
10201021each property will be tested for including the non-enumerable ` message ` and
10211022` name ` properties.
10221023
1023- If specified, ` message ` will be the message provided by the ` AssertionError ` if
1024- the ` asyncFn ` fails to reject.
1024+ If specified, ` message ` will be the message provided by the [ ` AssertionError ` ] [ ]
1025+ if the ` asyncFn ` fails to reject.
10251026
10261027``` js
10271028(async () => {
@@ -1096,11 +1097,11 @@ assert.strictEqual(1, '1', new TypeError('Inputs are not identical'));
10961097// TypeError: Inputs are not identical
10971098```
10981099
1099- If the values are not strictly equal, an ` AssertionError ` is thrown with a
1100+ If the values are not strictly equal, an [ ` AssertionError ` ] [ ] is thrown with a
11001101` message ` property set equal to the value of the ` message ` parameter. If the
11011102` message ` parameter is undefined, a default error message is assigned. If the
11021103` message ` parameter is an instance of an [ ` Error ` ] [ ] then it will be thrown
1103- instead of the ` AssertionError ` .
1104+ instead of the [ ` AssertionError ` ] [ ] .
11041105
11051106## ` assert.throws(fn[, error][, message]) `
11061107<!-- YAML
@@ -1231,6 +1232,9 @@ assert.throws(
12311232
12321233Custom error validation:
12331234
1235+ The function must return ` true ` to indicate all internal validations passed.
1236+ It will otherwise fail with an [ ` AssertionError ` ] [ ] .
1237+
12341238``` js
12351239assert .throws (
12361240 () => {
@@ -1295,6 +1299,7 @@ assert.throws(throwingFirst, /Second$/);
12951299Due to the confusing error-prone notation, avoid a string as the second
12961300argument.
12971301
1302+ [ `AssertionError` ] : #assert_class_assert_assertionerror
12981303[ `Class` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes
12991304[ `ERR_INVALID_RETURN_VALUE` ] : errors.html#errors_err_invalid_return_value
13001305[ `Error.captureStackTrace` ] : errors.html#errors_error_capturestacktrace_targetobject_constructoropt
0 commit comments