@@ -268,10 +268,14 @@ destructuring and call methods directly on the instance.
268268
269269<!-- YAML
270270added: v0.5.9
271+ changes:
272+ - version: REPLACEME
273+ pr-url: https://github.com/nodejs/node/pull/58849
274+ description: Message may now be a `printf`-like format string or function.
271275-->
272276
273277* ` value ` {any} The input that is checked for being truthy.
274- * ` message ` {string|Error}
278+ * ` message ` {string|Error|Function }
275279
276280An alias of [ ` assert.ok() ` ] [ ] .
277281
@@ -287,6 +291,9 @@ changes:
287291 - version: REPLACEME
288292 pr-url: https://github.com/nodejs/node/pull/57627
289293 description: Invalid dates are now considered equal.
294+ - version: REPLACEME
295+ pr-url: https://github.com/nodejs/node/pull/58849
296+ description: Message may now be a `printf`-like format string or function.
290297 - version: v24.0.0
291298 pr-url: https://github.com/nodejs/node/pull/57622
292299 description: Recursion now stops when either side encounters a circular
@@ -338,7 +345,7 @@ changes:
338345
339346* ` actual ` {any}
340347* ` expected ` {any}
341- * ` message ` {string|Error}
348+ * ` message ` {string|Error|Function }
342349
343350** Strict assertion mode**
344351
@@ -487,6 +494,9 @@ changes:
487494 - version: REPLACEME
488495 pr-url: https://github.com/nodejs/node/pull/57627
489496 description: Invalid dates are now considered equal.
497+ - version: REPLACEME
498+ pr-url: https://github.com/nodejs/node/pull/58849
499+ description: Message may now be a `printf`-like format string or function.
490500 - version: v24.0.0
491501 pr-url: https://github.com/nodejs/node/pull/57622
492502 description: Recursion now stops when either side encounters a circular
@@ -530,7 +540,7 @@ changes:
530540
531541* ` actual ` {any}
532542* ` expected ` {any}
533- * ` message ` {string|Error}
543+ * ` message ` {string|Error|Function }
534544
535545Tests for deep equality between the ` actual ` and ` expected ` parameters.
536546"Deep" equality means that the enumerable "own" properties of child objects
@@ -792,14 +802,17 @@ added:
792802 - v13.6.0
793803 - v12.16.0
794804changes:
805+ - version: REPLACEME
806+ pr-url: https://github.com/nodejs/node/pull/58849
807+ description: Message may now be a `printf`-like format string or function.
795808 - version: v16.0.0
796809 pr-url: https://github.com/nodejs/node/pull/38111
797810 description: This API is no longer experimental.
798811-->
799812
800813* ` string ` {string}
801814* ` regexp ` {RegExp}
802- * ` message ` {string|Error}
815+ * ` message ` {string|Error|Function }
803816
804817Expects the ` string ` input not to match the regular expression.
805818
@@ -1032,6 +1045,9 @@ assert.doesNotThrow(
10321045<!-- YAML
10331046added: v0.1.21
10341047changes:
1048+ - version: REPLACEME
1049+ pr-url: https://github.com/nodejs/node/pull/58849
1050+ description: Message may now be a `printf`-like format string or function.
10351051 - version:
10361052 - v16.0.0
10371053 - v14.18.0
@@ -1046,7 +1062,7 @@ changes:
10461062
10471063* ` actual ` {any}
10481064* ` expected ` {any}
1049- * ` message ` {string|Error}
1065+ * ` message ` {string|Error|Function }
10501066
10511067** Strict assertion mode**
10521068
@@ -1217,14 +1233,17 @@ added:
12171233 - v13.6.0
12181234 - v12.16.0
12191235changes:
1236+ - version: REPLACEME
1237+ pr-url: https://github.com/nodejs/node/pull/58849
1238+ description: Message may now be a `printf`-like format string or function.
12201239 - version: v16.0.0
12211240 pr-url: https://github.com/nodejs/node/pull/38111
12221241 description: This API is no longer experimental.
12231242-->
12241243
12251244* ` string ` {string}
12261245* ` regexp ` {RegExp}
1227- * ` message ` {string|Error}
1246+ * ` message ` {string|Error|Function }
12281247
12291248Expects the ` string ` input to match the regular expression.
12301249
@@ -1266,6 +1285,9 @@ instance of {Error} then it will be thrown instead of the
12661285<!-- YAML
12671286added: v0.1.21
12681287changes:
1288+ - version: REPLACEME
1289+ pr-url: https://github.com/nodejs/node/pull/58849
1290+ description: Message may now be a `printf`-like format string or function.
12691291 - version:
12701292 - v16.0.0
12711293 - v14.18.0
@@ -1301,7 +1323,7 @@ changes:
13011323
13021324* ` actual ` {any}
13031325* ` expected ` {any}
1304- * ` message ` {string|Error}
1326+ * ` message ` {string|Error|Function }
13051327
13061328** Strict assertion mode**
13071329
@@ -1390,6 +1412,9 @@ instead of the `AssertionError`.
13901412<!-- YAML
13911413added: v1.2.0
13921414changes:
1415+ - version: REPLACEME
1416+ pr-url: https://github.com/nodejs/node/pull/58849
1417+ description: Message may now be a `printf`-like format string or function.
13931418 - version: v9.0.0
13941419 pr-url: https://github.com/nodejs/node/pull/15398
13951420 description: The `-0` and `+0` are not considered equal anymore.
@@ -1421,7 +1446,7 @@ changes:
14211446
14221447* ` actual ` {any}
14231448* ` expected ` {any}
1424- * ` message ` {string|Error}
1449+ * ` message ` {string|Error|Function }
14251450
14261451Tests for deep strict inequality. Opposite of [ ` assert.deepStrictEqual() ` ] [ ] .
14271452
@@ -1450,6 +1475,9 @@ instead of the [`AssertionError`][].
14501475<!-- YAML
14511476added: v0.1.21
14521477changes:
1478+ - version: REPLACEME
1479+ pr-url: https://github.com/nodejs/node/pull/58849
1480+ description: Message may now be a `printf`-like format string or function.
14531481 - version:
14541482 - v16.0.0
14551483 - v14.18.0
@@ -1464,7 +1492,7 @@ changes:
14641492
14651493* ` actual ` {any}
14661494* ` expected ` {any}
1467- * ` message ` {string|Error}
1495+ * ` message ` {string|Error|Function }
14681496
14691497** Strict assertion mode**
14701498
@@ -1514,14 +1542,17 @@ parameter is an instance of {Error} then it will be thrown instead of the
15141542<!-- YAML
15151543added: v0.1.21
15161544changes:
1545+ - version: REPLACEME
1546+ pr-url: https://github.com/nodejs/node/pull/58849
1547+ description: Message may now be a `printf`-like format string or function.
15171548 - version: v10.0.0
15181549 pr-url: https://github.com/nodejs/node/pull/17003
15191550 description: Used comparison changed from Strict Equality to `Object.is()`.
15201551-->
15211552
15221553* ` actual ` {any}
15231554* ` expected ` {any}
1524- * ` message ` {string|Error}
1555+ * ` message ` {string|Error|Function }
15251556
15261557Tests strict inequality between the ` actual ` and ` expected ` parameters as
15271558determined by [ ` Object.is() ` ] [ ] .
@@ -1567,14 +1598,17 @@ instead of the `AssertionError`.
15671598<!-- YAML
15681599added: v0.1.21
15691600changes:
1601+ - version: REPLACEME
1602+ pr-url: https://github.com/nodejs/node/pull/58849
1603+ description: Message may now be a `printf`-like format string or function.
15701604 - version: v10.0.0
15711605 pr-url: https://github.com/nodejs/node/pull/18319
15721606 description: The `assert.ok()` (no arguments) will now use a predefined
15731607 error message.
15741608-->
15751609
15761610* ` value ` {any}
1577- * ` message ` {string|Error}
1611+ * ` message ` {string|Error|Function }
15781612
15791613Tests if ` value ` is truthy. It is equivalent to
15801614` assert.equal(!!value, true, message) ` .
@@ -1808,7 +1842,7 @@ argument gets considered.
18081842added: v0.1.21
18091843changes:
18101844 - version: REPLACEME
1811- pr-url: https://github.com/nodejs/node/pull/XXXXX
1845+ pr-url: https://github.com/nodejs/node/pull/58849
18121846 description: Message may now be a `printf`-like format string or function.
18131847 - version: v10.0.0
18141848 pr-url: https://github.com/nodejs/node/pull/17003
@@ -1859,11 +1893,11 @@ assert.strictEqual(apples, oranges, 'apples %s !== oranges %s', apples, oranges)
18591893assert .strictEqual (1 , ' 1' , new TypeError (' Inputs are not identical' ));
18601894// TypeError: Inputs are not identical
18611895
1862- assert .strictEqual (apples, oranges, () => {
1896+ assert .strictEqual (apples, oranges, (actual , expected ) => {
18631897 // Do 'heavy' computations
1864- return ' My error string ' ;
1898+ return ` I expected ${ expected } but I got ${ actual } ` ;
18651899});
1866- // AssertionError [ERR_ASSERTION]: apples 1 !== oranges 2
1900+ // AssertionError [ERR_ASSERTION]: I expected oranges but I got apples
18671901```
18681902
18691903``` cjs
@@ -1890,8 +1924,17 @@ const oranges = 2;
18901924assert .strictEqual (apples, oranges, ` apples ${ apples} !== oranges ${ oranges} ` );
18911925// AssertionError [ERR_ASSERTION]: apples 1 !== oranges 2
18921926
1927+ assert .strictEqual (apples, oranges, ' apples %s !== oranges %s' , apples, oranges);
1928+ // AssertionError [ERR_ASSERTION]: apples 1 !== oranges 2
1929+
18931930assert .strictEqual (1 , ' 1' , new TypeError (' Inputs are not identical' ));
18941931// TypeError: Inputs are not identical
1932+
1933+ assert .strictEqual (apples, oranges, (actual , expected ) => {
1934+ // Do 'heavy' computations
1935+ return ` I expected ${ expected} but I got ${ actual} ` ;
1936+ });
1937+ // AssertionError [ERR_ASSERTION]: I expected oranges but I got apples
18951938```
18961939
18971940If the values are not strictly equal, an [ ` AssertionError ` ] [ ] is thrown with a
0 commit comments