@@ -1071,107 +1071,6 @@ assert.fail(new TypeError('need array'));
1071
1071
// TypeError: need array
1072
1072
```
1073
1073
1074
- Using ` assert.fail() ` with more than two arguments is possible but deprecated.
1075
- See below for further details.
1076
-
1077
- ## ` assert.fail(actual, expected[, message[, operator[, stackStartFn]]]) `
1078
-
1079
- <!-- YAML
1080
- added: v0.1.21
1081
- changes:
1082
- - version: v10.0.0
1083
- pr-url: https://github.com/nodejs/node/pull/18418
1084
- description: Calling `assert.fail()` with more than one argument is
1085
- deprecated and emits a warning.
1086
- -->
1087
-
1088
- > Stability: 0 - Deprecated: Use ` assert.fail([message]) ` or other assert
1089
- > functions instead.
1090
-
1091
- * ` actual ` {any}
1092
- * ` expected ` {any}
1093
- * ` message ` {string|Error}
1094
- * ` operator ` {string} ** Default:** ` '!=' `
1095
- * ` stackStartFn ` {Function} ** Default:** ` assert.fail `
1096
-
1097
- If ` message ` is falsy, the error message is set as the values of ` actual ` and
1098
- ` expected ` separated by the provided ` operator ` . If just the two ` actual ` and
1099
- ` expected ` arguments are provided, ` operator ` will default to ` '!=' ` . If
1100
- ` message ` is provided as third argument it will be used as the error message and
1101
- the other arguments will be stored as properties on the thrown object. If
1102
- ` stackStartFn ` is provided, all stack frames above that function will be
1103
- removed from stacktrace (see [ ` Error.captureStackTrace ` ] [ ] ). If no arguments are
1104
- given, the default message ` Failed ` will be used.
1105
-
1106
- ``` mjs
1107
- import assert from ' node:assert/strict' ;
1108
-
1109
- assert .fail (' a' , ' b' );
1110
- // AssertionError [ERR_ASSERTION]: 'a' != 'b'
1111
-
1112
- assert .fail (1 , 2 , undefined , ' >' );
1113
- // AssertionError [ERR_ASSERTION]: 1 > 2
1114
-
1115
- assert .fail (1 , 2 , ' fail' );
1116
- // AssertionError [ERR_ASSERTION]: fail
1117
-
1118
- assert .fail (1 , 2 , ' whoops' , ' >' );
1119
- // AssertionError [ERR_ASSERTION]: whoops
1120
-
1121
- assert .fail (1 , 2 , new TypeError (' need array' ));
1122
- // TypeError: need array
1123
- ```
1124
-
1125
- ``` cjs
1126
- const assert = require (' node:assert/strict' );
1127
-
1128
- assert .fail (' a' , ' b' );
1129
- // AssertionError [ERR_ASSERTION]: 'a' != 'b'
1130
-
1131
- assert .fail (1 , 2 , undefined , ' >' );
1132
- // AssertionError [ERR_ASSERTION]: 1 > 2
1133
-
1134
- assert .fail (1 , 2 , ' fail' );
1135
- // AssertionError [ERR_ASSERTION]: fail
1136
-
1137
- assert .fail (1 , 2 , ' whoops' , ' >' );
1138
- // AssertionError [ERR_ASSERTION]: whoops
1139
-
1140
- assert .fail (1 , 2 , new TypeError (' need array' ));
1141
- // TypeError: need array
1142
- ```
1143
-
1144
- In the last three cases ` actual ` , ` expected ` , and ` operator ` have no
1145
- influence on the error message.
1146
-
1147
- Example use of ` stackStartFn ` for truncating the exception's stacktrace:
1148
-
1149
- ``` mjs
1150
- import assert from ' node:assert/strict' ;
1151
-
1152
- function suppressFrame () {
1153
- assert .fail (' a' , ' b' , undefined , ' !==' , suppressFrame);
1154
- }
1155
- suppressFrame ();
1156
- // AssertionError [ERR_ASSERTION]: 'a' !== 'b'
1157
- // at repl:1:1
1158
- // at ContextifyScript.Script.runInThisContext (vm.js:44:33)
1159
- // ...
1160
- ```
1161
-
1162
- ``` cjs
1163
- const assert = require (' node:assert/strict' );
1164
-
1165
- function suppressFrame () {
1166
- assert .fail (' a' , ' b' , undefined , ' !==' , suppressFrame);
1167
- }
1168
- suppressFrame ();
1169
- // AssertionError [ERR_ASSERTION]: 'a' !== 'b'
1170
- // at repl:1:1
1171
- // at ContextifyScript.Script.runInThisContext (vm.js:44:33)
1172
- // ...
1173
- ```
1174
-
1175
1074
## ` assert.ifError(value) `
1176
1075
1177
1076
<!-- YAML
@@ -2437,7 +2336,6 @@ assert.partialDeepStrictEqual(
2437
2336
[ `AssertionError` ] : #class-assertassertionerror
2438
2337
[ `Class` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes
2439
2338
[ `ERR_INVALID_RETURN_VALUE` ] : errors.md#err_invalid_return_value
2440
- [ `Error.captureStackTrace` ] : errors.md#errorcapturestacktracetargetobject-constructoropt
2441
2339
[ `Object.is()` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
2442
2340
[ `assert.deepEqual()` ] : #assertdeepequalactual-expected-message
2443
2341
[ `assert.deepStrictEqual()` ] : #assertdeepstrictequalactual-expected-message
0 commit comments