From ddaf34d6e97269719107398569716fc1f1e98073 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 5 Sep 2023 19:03:44 -0300 Subject: infra, test: cleaner output for stubTemplate --- test/lib/content-function.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'test') 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}`; + } }); }; -- cgit 1.3.0-6-gf8a5