@@ -214,8 +214,9 @@ are also recursively evaluated by the following rules.
214
214
* [ ` Symbol ` ] [ ] properties are not compared.
215
215
* [ ` WeakMap ` ] [ ] and [ ` WeakSet ` ] [ ] comparison does not rely on their values.
216
216
217
- The following example does not throw an ` AssertionError ` because the primitives
218
- are considered equal by the [ Abstract Equality Comparison] [ ] ( ` == ` ).
217
+ The following example does not throw an [ ` AssertionError ` ] [ ] because the
218
+ primitives are considered equal by the [ Abstract Equality Comparison] [ ]
219
+ ( ` == ` ).
219
220
220
221
``` js
221
222
// WARNING: This does not throw an AssertionError!
@@ -260,11 +261,11 @@ assert.deepEqual(obj1, obj4);
260
261
// AssertionError: { a: { b: 1 } } deepEqual {}
261
262
```
262
263
263
- If the values are not equal, an ` AssertionError ` is thrown with a ` message `
264
+ If the values are not equal, an [ ` AssertionError ` ] [ ] is thrown with a ` message `
264
265
property set equal to the value of the ` message ` parameter. If the ` message `
265
266
parameter is undefined, a default error message is assigned. If the ` message `
266
267
parameter is an instance of an [ ` Error ` ] [ ] then it will be thrown instead of the
267
- ` AssertionError ` .
268
+ [ ` AssertionError ` ] [ ] .
268
269
269
270
## assert.deepStrictEqual(actual, expected[ , message] )
270
271
<!-- YAML
@@ -414,7 +415,7 @@ assert.deepStrictEqual(weakMap1, weakMap3);
414
415
// }
415
416
```
416
417
417
- If the values are not equal, an ` AssertionError ` is thrown with a ` message `
418
+ If the values are not equal, an [ ` AssertionError ` ] [ ] is thrown with a ` message `
418
419
property set equal to the value of the ` message ` parameter. If the ` message `
419
420
parameter is undefined, a default error message is assigned. If the ` message `
420
421
parameter is an instance of an [ ` Error ` ] [ ] then it will be thrown instead of the
@@ -497,9 +498,9 @@ When `assert.doesNotThrow()` is called, it will immediately call the `fn`
497
498
function.
498
499
499
500
If an error is thrown and it is the same type as that specified by the ` error `
500
- parameter, then an ` AssertionError ` is thrown. If the error is of a different
501
- type, or if the ` error ` parameter is undefined, the error is propagated back
502
- to the caller.
501
+ parameter, then an [ ` AssertionError ` ] [ ] is thrown. If the error is of a
502
+ different type, or if the ` error ` parameter is undefined, the error is
503
+ propagated back to the caller.
503
504
504
505
If specified, ` error ` can be a [ ` Class ` ] [ ] , [ ` RegExp ` ] [ ] or a validation
505
506
function. See [ ` assert.throws() ` ] [ ] for more details.
@@ -517,7 +518,7 @@ assert.doesNotThrow(
517
518
);
518
519
```
519
520
520
- However, the following will result in an ` AssertionError ` with the message
521
+ However, the following will result in an [ ` AssertionError ` ] [ ] with the message
521
522
'Got unwanted exception...':
522
523
523
524
<!-- eslint-disable no-restricted-syntax -->
@@ -530,8 +531,8 @@ assert.doesNotThrow(
530
531
);
531
532
```
532
533
533
- If an ` AssertionError ` is thrown and a value is provided for the ` message `
534
- parameter, the value of ` message ` will be appended to the ` AssertionError `
534
+ If an [ ` AssertionError ` ] [ ] is thrown and a value is provided for the ` message `
535
+ parameter, the value of ` message ` will be appended to the [ ` AssertionError ` ] [ ]
535
536
message:
536
537
537
538
<!-- eslint-disable no-restricted-syntax -->
@@ -580,7 +581,7 @@ assert.equal({ a: { b: 1 } }, { a: { b: 1 } });
580
581
// AssertionError: { a: { b: 1 } } == { a: { b: 1 } }
581
582
```
582
583
583
- If the values are not equal, an ` AssertionError ` is thrown with a ` message `
584
+ If the values are not equal, an [ ` AssertionError ` ] [ ] is thrown with a ` message `
584
585
property set equal to the value of the ` message ` parameter. If the ` message `
585
586
parameter is undefined, a default error message is assigned. If the ` message `
586
587
parameter is an instance of an [ ` Error ` ] [ ] then it will be thrown instead of the
@@ -593,9 +594,9 @@ added: v0.1.21
593
594
594
595
* ` message ` {string|Error} ** Default:** ` 'Failed' `
595
596
596
- Throws an ` AssertionError ` with the provided error message or a default error
597
- message. If the ` message ` parameter is an instance of an [ ` Error ` ] [ ] then it
598
- will be thrown instead of the ` AssertionError ` .
597
+ Throws an [ ` AssertionError ` ] [ ] with the provided error message or a default
598
+ error message. If the ` message ` parameter is an instance of an [ ` Error ` ] [ ] then
599
+ it will be thrown instead of the [ ` AssertionError ` ] [ ] .
599
600
600
601
``` js
601
602
const assert = require (' assert' ).strict ;
@@ -683,7 +684,7 @@ changes:
683
684
- version: v10.0.0
684
685
pr-url: https://github.com/nodejs/node/pull/18247
685
686
description: Instead of throwing the original error it is now wrapped into
686
- an `AssertionError` that contains the full stack trace.
687
+ an [ `AssertionError`][] that contains the full stack trace.
687
688
- version: v10.0.0
688
689
pr-url: https://github.com/nodejs/node/pull/18247
689
690
description: Value may now only be `undefined` or `null`. Before all falsy
@@ -791,11 +792,11 @@ assert.notDeepEqual(obj1, obj4);
791
792
// OK
792
793
```
793
794
794
- If the values are deeply equal, an ` AssertionError ` is thrown with a ` message `
795
- property set equal to the value of the ` message ` parameter. If the ` message `
796
- parameter is undefined, a default error message is assigned. If the ` message `
797
- parameter is an instance of an [ ` Error ` ] [ ] then it will be thrown instead of the
798
- ` AssertionError ` .
795
+ If the values are deeply equal, an [ ` AssertionError ` ] [ ] is thrown with a
796
+ ` message ` property set equal to the value of the ` message ` parameter. If the
797
+ ` message ` parameter is undefined, a default error message is assigned. If the
798
+ ` message ` parameter is an instance of an [ ` Error ` ] [ ] then it will be thrown
799
+ instead of the ` AssertionError ` .
799
800
800
801
## assert.notDeepStrictEqual(actual, expected[ , message] )
801
802
<!-- YAML
@@ -839,11 +840,11 @@ assert.notDeepStrictEqual({ a: 1 }, { a: '1' });
839
840
// OK
840
841
```
841
842
842
- If the values are deeply and strictly equal, an ` AssertionError ` is thrown with
843
- a ` message ` property set equal to the value of the ` message ` parameter. If the
844
- ` message ` parameter is undefined, a default error message is assigned. If the
845
- ` message ` parameter is an instance of an [ ` Error ` ] [ ] then it will be thrown
846
- instead of the ` AssertionError ` .
843
+ If the values are deeply and strictly equal, an [ ` AssertionError ` ] [ ] is thrown
844
+ with a ` message ` property set equal to the value of the ` message ` parameter. If
845
+ the ` message ` parameter is undefined, a default error message is assigned. If
846
+ the ` message ` parameter is an instance of an [ ` Error ` ] [ ] then it will be thrown
847
+ instead of the [ ` AssertionError ` ] [ ] .
847
848
848
849
## assert.notEqual(actual, expected[ , message] )
849
850
<!-- YAML
@@ -878,10 +879,10 @@ assert.notEqual(1, '1');
878
879
// AssertionError: 1 != '1'
879
880
```
880
881
881
- If the values are equal, an ` AssertionError ` is thrown with a ` message ` property
882
- set equal to the value of the ` message ` parameter. If the ` message ` parameter is
883
- undefined, a default error message is assigned. If the ` message ` parameter is an
884
- instance of an [ ` Error ` ] [ ] then it will be thrown instead of the
882
+ If the values are equal, an [ ` AssertionError ` ] [ ] is thrown with a ` message `
883
+ property set equal to the value of the ` message ` parameter. If the ` message `
884
+ parameter is undefined, a default error message is assigned. If the ` message `
885
+ parameter is an instance of an [ ` Error ` ] [ ] then it will be thrown instead of the
885
886
` AssertionError ` .
886
887
887
888
## assert.notStrictEqual(actual, expected[ , message] )
@@ -915,11 +916,11 @@ assert.notStrictEqual(1, '1');
915
916
// OK
916
917
```
917
918
918
- If the values are strictly equal, an ` AssertionError ` is thrown with a ` message `
919
- property set equal to the value of the ` message ` parameter. If the ` message `
920
- parameter is undefined, a default error message is assigned. If the ` message `
921
- parameter is an instance of an [ ` Error ` ] [ ] then it will be thrown instead of the
922
- ` AssertionError ` .
919
+ If the values are strictly equal, an [ ` AssertionError ` ] [ ] is thrown with a
920
+ ` message ` property set equal to the value of the ` message ` parameter. If the
921
+ ` message ` parameter is undefined, a default error message is assigned. If the
922
+ ` message ` parameter is an instance of an [ ` Error ` ] [ ] then it will be thrown
923
+ instead of the ` AssertionError ` .
923
924
924
925
## assert.ok(value[ , message] )
925
926
<!-- YAML
@@ -937,7 +938,7 @@ changes:
937
938
Tests if ` value ` is truthy. It is equivalent to
938
939
` assert.equal(!!value, true, message) ` .
939
940
940
- If ` value ` is not truthy, an ` AssertionError ` is thrown with a ` message `
941
+ If ` value ` is not truthy, an [ ` AssertionError ` ] [ ] is thrown with a ` message `
941
942
property set equal to the value of the ` message ` parameter. If the ` message `
942
943
parameter is ` undefined ` , a default error message is assigned. If the ` message `
943
944
parameter is an instance of an [ ` Error ` ] [ ] then it will be thrown instead of the
@@ -1016,8 +1017,8 @@ an object where each property will be tested for, or an instance of error where
1016
1017
each property will be tested for including the non-enumerable ` message ` and
1017
1018
` name ` properties.
1018
1019
1019
- If specified, ` message ` will be the message provided by the ` AssertionError ` if
1020
- the ` asyncFn ` fails to reject.
1020
+ If specified, ` message ` will be the message provided by the [ ` AssertionError ` ] [ ]
1021
+ if the ` asyncFn ` fails to reject.
1021
1022
1022
1023
``` js
1023
1024
(async () => {
@@ -1092,11 +1093,11 @@ assert.strictEqual(1, '1', new TypeError('Inputs are not identical'));
1092
1093
// TypeError: Inputs are not identical
1093
1094
```
1094
1095
1095
- If the values are not strictly equal, an ` AssertionError ` is thrown with a
1096
+ If the values are not strictly equal, an [ ` AssertionError ` ] [ ] is thrown with a
1096
1097
` message ` property set equal to the value of the ` message ` parameter. If the
1097
1098
` message ` parameter is undefined, a default error message is assigned. If the
1098
1099
` message ` parameter is an instance of an [ ` Error ` ] [ ] then it will be thrown
1099
- instead of the ` AssertionError ` .
1100
+ instead of the [ ` AssertionError ` ] [ ] .
1100
1101
1101
1102
## assert.throws(fn[ , error] [ , message ] )
1102
1103
<!-- YAML
@@ -1228,7 +1229,7 @@ assert.throws(
1228
1229
Custom error validation:
1229
1230
1230
1231
The function must return ` true ` to indicate all internal validations passed.
1231
- It will otherwise fail with an AssertionError.
1232
+ It will otherwise fail with an [ ` AssertionError ` ] [ ] .
1232
1233
1233
1234
``` js
1234
1235
assert .throws (
@@ -1292,6 +1293,7 @@ assert.throws(throwingFirst, /Second$/);
1292
1293
Due to the confusing notation, it is recommended not to use a string as the
1293
1294
second argument. This might lead to difficult-to-spot errors.
1294
1295
1296
+ [ `AssertionError` ] : #assert_class_assert_assertionerror
1295
1297
[ `Class` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes
1296
1298
[ `ERR_INVALID_RETURN_VALUE` ] : errors.html#errors_err_invalid_return_value
1297
1299
[ `Error.captureStackTrace` ] : errors.html#errors_error_capturestacktrace_targetobject_constructoropt
0 commit comments