]> git.codecow.com Git - libnemo.git/commitdiff
Add JSdoc typing to rejection test harness and return its error for further inspectio...
authorChris Duncan <chris@zoso.dev>
Thu, 23 Apr 2026 21:45:49 +0000 (14:45 -0700)
committerChris Duncan <chris@zoso.dev>
Thu, 23 Apr 2026 21:45:49 +0000 (14:45 -0700)
test/GLOBALS.mjs

index deca184ff594ca891c2bf028c44f45317f44a6ef..d94c75b97ac9c019b9af033332ffd990b50ce6b7 100644 (file)
@@ -263,6 +263,11 @@ export class assert {
                }
        }
 
+       /**
+        * @param {(Function | Promise<any>)} fn
+        * @param {string} [msg]
+        * @returns {Promise<Error>}
+        */
        static async rejects (fn, msg) {
                if (fn.constructor.name === 'AsyncFunction') {
                        fn = fn()
@@ -271,7 +276,9 @@ export class assert {
                        try {
                                await fn
                                throw new Error(msg ?? 'expected async function to reject')
-                       } catch { }
+                       } catch (err) {
+                               return err
+                       }
                } else {
                        throw new Error(msg ?? 'expected async function')
                }