From decff38f97f5535d0d67f0a315751ba01b5ce1b6 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Thu, 5 Dec 2024 22:09:44 -0800 Subject: [PATCH] Get message from failure errors. --- GLOBALS.mjs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/GLOBALS.mjs b/GLOBALS.mjs index 1b60059..a9c6c39 100644 --- a/GLOBALS.mjs +++ b/GLOBALS.mjs @@ -24,17 +24,17 @@ export function test (name, fn) { if (fn instanceof Promise) { try { fn.then(() => console.log(`PASS: ${name}`)) - .catch((err) => console.error(`FAIL: ${name}`)) + .catch((err) => console.error(`FAIL: ${name}: ${err.message}`)) } catch (err) { - console.error(`FAIL: ${name}`) + console.error(`FAIL: ${name}: ${err.message}`) console.error(err) } } else if (fn.constructor.name === 'AsyncFunction') { try { fn().then(() => console.log(`PASS: ${name}`)) - .catch((err) => console.error(`FAIL: ${name}`)) + .catch((err) => console.error(`FAIL: ${name}: ${err.message}`)) } catch (err) { - console.error(`FAIL: ${name}`) + console.error(`FAIL: ${name}: ${err.message}`) console.error(err) } } else { @@ -42,7 +42,7 @@ export function test (name, fn) { fn() console.log(`PASS: ${name}`) } catch (err) { - console.error(`FAIL: ${name}`) + console.error(`FAIL: ${name}: ${err.message}`) console.error(err) } } @@ -59,11 +59,10 @@ export const assert = { return true }, exists: (a) => { - let b = a || null - if (b == null) { + if (!!a === false) { throw new Error(`argument is ${typeof a}`) } - return b != null + return a != null }, equals: (a, b) => { if (a !== b) { -- 2.34.1