@@ -105,6 +105,14 @@ function innerFail(obj) {
105105 throw new AssertionError ( obj ) ;
106106}
107107
108+ /**
109+ * @param {any } actual
110+ * @param {any } expected
111+ * @param {string | Error } [message]
112+ * @param {string } [operator]
113+ * @param {Function } [stackStartFn]
114+ * @returns {never }
115+ */
108116function fail ( actual , expected , message , operator , stackStartFn ) {
109117 const argsLen = arguments . length ;
110118
@@ -384,14 +392,24 @@ function innerOk(fn, argLen, value, message) {
384392 }
385393}
386394
387- // Pure assertion tests whether a value is truthy, as determined
388- // by !!value.
395+ /**
396+ * Pure assertion tests whether a value is truthy, as determined
397+ * by !!value.
398+ * @param {...any } args
399+ * @returns {void }
400+ */
389401function ok ( ...args ) {
390402 innerOk ( ok , args . length , ...args ) ;
391403}
392404assert . ok = ok ;
393405
394- // The equality assertion tests shallow, coercive equality with ==.
406+ /**
407+ * The equality assertion tests shallow, coercive equality with ==.
408+ * @param {any } actual
409+ * @param {any } expected
410+ * @param {string | Error } [message]
411+ * @returns {void }
412+ */
395413/* eslint-disable no-restricted-properties */
396414assert . equal = function equal ( actual , expected , message ) {
397415 if ( arguments . length < 2 ) {
@@ -409,8 +427,14 @@ assert.equal = function equal(actual, expected, message) {
409427 }
410428} ;
411429
412- // The non-equality assertion tests for whether two objects are not
413- // equal with !=.
430+ /**
431+ * The non-equality assertion tests for whether two objects are not
432+ * equal with !=.
433+ * @param {any } actual
434+ * @param {any } expected
435+ * @param {string | Error } [message]
436+ * @returns {void }
437+ */
414438assert . notEqual = function notEqual ( actual , expected , message ) {
415439 if ( arguments . length < 2 ) {
416440 throw new ERR_MISSING_ARGS ( 'actual' , 'expected' ) ;
@@ -427,7 +451,13 @@ assert.notEqual = function notEqual(actual, expected, message) {
427451 }
428452} ;
429453
430- // The equivalence assertion tests a deep equality relation.
454+ /**
455+ * The deep equivalence assertion tests a deep equality relation.
456+ * @param {any } actual
457+ * @param {any } expected
458+ * @param {string | Error } [message]
459+ * @returns {void }
460+ */
431461assert . deepEqual = function deepEqual ( actual , expected , message ) {
432462 if ( arguments . length < 2 ) {
433463 throw new ERR_MISSING_ARGS ( 'actual' , 'expected' ) ;
@@ -444,7 +474,13 @@ assert.deepEqual = function deepEqual(actual, expected, message) {
444474 }
445475} ;
446476
447- // The non-equivalence assertion tests for any deep inequality.
477+ /**
478+ * The deep non-equivalence assertion tests for any deep inequality.
479+ * @param {any } actual
480+ * @param {any } expected
481+ * @param {string | Error } [message]
482+ * @returns {void }
483+ */
448484assert . notDeepEqual = function notDeepEqual ( actual , expected , message ) {
449485 if ( arguments . length < 2 ) {
450486 throw new ERR_MISSING_ARGS ( 'actual' , 'expected' ) ;
@@ -462,6 +498,14 @@ assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
462498} ;
463499/* eslint-enable */
464500
501+ /**
502+ * The deep strict equivalence assertion tests a deep strict equality
503+ * relation.
504+ * @param {any } actual
505+ * @param {any } expected
506+ * @param {string | Error } [message]
507+ * @returns {void }
508+ */
465509assert . deepStrictEqual = function deepStrictEqual ( actual , expected , message ) {
466510 if ( arguments . length < 2 ) {
467511 throw new ERR_MISSING_ARGS ( 'actual' , 'expected' ) ;
@@ -478,6 +522,14 @@ assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
478522 }
479523} ;
480524
525+ /**
526+ * The deep strict non-equivalence assertion tests for any deep strict
527+ * inequality.
528+ * @param {any } actual
529+ * @param {any } expected
530+ * @param {string | Error } [message]
531+ * @returns {void }
532+ */
481533assert . notDeepStrictEqual = notDeepStrictEqual ;
482534function notDeepStrictEqual ( actual , expected , message ) {
483535 if ( arguments . length < 2 ) {
@@ -495,6 +547,13 @@ function notDeepStrictEqual(actual, expected, message) {
495547 }
496548}
497549
550+ /**
551+ * The strict equivalence assertion tests a strict equality relation.
552+ * @param {any } actual
553+ * @param {any } expected
554+ * @param {string | Error } [message]
555+ * @returns {void }
556+ */
498557assert . strictEqual = function strictEqual ( actual , expected , message ) {
499558 if ( arguments . length < 2 ) {
500559 throw new ERR_MISSING_ARGS ( 'actual' , 'expected' ) ;
@@ -510,6 +569,13 @@ assert.strictEqual = function strictEqual(actual, expected, message) {
510569 }
511570} ;
512571
572+ /**
573+ * The strict non-equivalence assertion tests for any strict inequality.
574+ * @param {any } actual
575+ * @param {any } expected
576+ * @param {string | Error } [message]
577+ * @returns {void }
578+ */
513579assert . notStrictEqual = function notStrictEqual ( actual , expected , message ) {
514580 if ( arguments . length < 2 ) {
515581 throw new ERR_MISSING_ARGS ( 'actual' , 'expected' ) ;
@@ -820,22 +886,51 @@ function expectsNoError(stackStartFn, actual, error, message) {
820886 throw actual ;
821887}
822888
889+ /**
890+ * Expects the function `promiseFn` to throw an error.
891+ * @param {() => any } promiseFn
892+ * @param {...any } [args]
893+ * @returns {void }
894+ */
823895assert . throws = function throws ( promiseFn , ...args ) {
824896 expectsError ( throws , getActual ( promiseFn ) , ...args ) ;
825897} ;
826898
899+ /**
900+ * Expects `promiseFn` function or its value to reject.
901+ * @param {() => Promise<any> } promiseFn
902+ * @param {...any } [args]
903+ * @returns {Promise<void> }
904+ */
827905assert . rejects = async function rejects ( promiseFn , ...args ) {
828906 expectsError ( rejects , await waitForActual ( promiseFn ) , ...args ) ;
829907} ;
830908
909+ /**
910+ * Asserts that the function `fn` does not throw an error.
911+ * @param {() => any } fn
912+ * @param {...any } [args]
913+ * @returns {void }
914+ */
831915assert . doesNotThrow = function doesNotThrow ( fn , ...args ) {
832916 expectsNoError ( doesNotThrow , getActual ( fn ) , ...args ) ;
833917} ;
834918
919+ /**
920+ * Expects `fn` or its value to not reject.
921+ * @param {() => Promise<any> } fn
922+ * @param {...any } [args]
923+ * @returns {Promise<void> }
924+ */
835925assert . doesNotReject = async function doesNotReject ( fn , ...args ) {
836926 expectsNoError ( doesNotReject , await waitForActual ( fn ) , ...args ) ;
837927} ;
838928
929+ /**
930+ * Throws `value` if the value is not `null` or `undefined`.
931+ * @param {any } err
932+ * @returns {void }
933+ */
839934assert . ifError = function ifError ( err ) {
840935 if ( err !== null && err !== undefined ) {
841936 let message = 'ifError got unwanted exception: ' ;
@@ -919,24 +1014,44 @@ function internalMatch(string, regexp, message, fn) {
9191014 }
9201015}
9211016
1017+ /**
1018+ * Expects the `string` input to match the regular expression.
1019+ * @param {string } string
1020+ * @param {RegExp } regexp
1021+ * @param {string | Error } [message]
1022+ * @returns {void }
1023+ */
9221024assert . match = function match ( string , regexp , message ) {
9231025 internalMatch ( string , regexp , message , match ) ;
9241026} ;
9251027
1028+ /**
1029+ * Expects the `string` input not to match the regular expression.
1030+ * @param {string } string
1031+ * @param {RegExp } regexp
1032+ * @param {string | Error } [message]
1033+ * @returns {void }
1034+ */
9261035assert . doesNotMatch = function doesNotMatch ( string , regexp , message ) {
9271036 internalMatch ( string , regexp , message , doesNotMatch ) ;
9281037} ;
9291038
9301039assert . CallTracker = CallTracker ;
9311040
932- // Expose a strict only variant of assert
1041+ /**
1042+ * Expose a strict only variant of assert.
1043+ * @param {...any } args
1044+ * @returns {void }
1045+ */
9331046function strict ( ...args ) {
9341047 innerOk ( strict , args . length , ...args ) ;
9351048}
1049+
9361050assert . strict = ObjectAssign ( strict , assert , {
9371051 equal : assert . strictEqual ,
9381052 deepEqual : assert . deepStrictEqual ,
9391053 notEqual : assert . notStrictEqual ,
9401054 notDeepEqual : assert . notDeepStrictEqual
9411055} ) ;
1056+
9421057assert . strict . strict = assert . strict ;
0 commit comments