diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-09-05 19:03:44 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-09-05 20:11:18 -0300 |
commit | ddaf34d6e97269719107398569716fc1f1e98073 (patch) | |
tree | 2d9d455afd39ea4387c4770ef79c70f6d417944e /test | |
parent | d194fc4f537ee79b0558b54ff2e1fdc3e9cbf4d9 (diff) |
infra, test: cleaner output for stubTemplate
Diffstat (limited to 'test')
-rw-r--r-- | test/lib/content-function.js | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/test/lib/content-function.js b/test/lib/content-function.js index bb12be82..b706cd8c 100644 --- a/test/lib/content-function.js +++ b/test/lib/content-function.js @@ -1,5 +1,6 @@ import * as path from 'node:path'; import {fileURLToPath} from 'node:url'; +import {inspect} from 'node:util'; import chroma from 'chroma-js'; @@ -99,7 +100,7 @@ export function testContentFunctions(t, message, fn) { constructor() { super({ - content: () => `${name}: ${JSON.stringify(this.#slotValues)}`, + content: () => this.#getContent(this), }); } @@ -110,6 +111,24 @@ export function testContentFunctions(t, message, fn) { setSlot(slotName, slotValue) { this.#slotValues[slotName] = slotValue; } + + #getContent() { + const toInspect = + Object.fromEntries( + Object.entries(this.#slotValues) + .filter(([key, value]) => value !== null)); + + const inspected = + inspect(toInspect, { + breakLength: Infinity, + colors: false, + compact: true, + depth: Infinity, + sort: true, + }); + + return `${name}: ${inspected}`; + } }); }; |