From 1e649dcf14e63167c67d5551f5b6bd4a78f3e9e7 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Fri, 22 Jan 2021 20:18:32 +0100 Subject: [PATCH 1/2] Test: Fix duplicate console logs --- karma.conf.js | 6 +++++- test/polyfills.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index 5765906c62..70fd26e40e 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -16,7 +16,9 @@ const fs = require('fs').promises; const orgStdoutWrite = process.stdout.write; process.stdout.write = msg => { let out = ''; - const match = msg.match(/(^|.*\s)(LOG|WARN|ERROR):\s'([\s\S]*)'/); + const match = msg.match( + /(^|.*\s)(LOG|WARN|ERROR):\s'__LOG_CUSTOM:([\S\s]*)'/ + ); if (match && match.length >= 4) { // Sometimes the UA of the browser will be included in the message if (match[1].length) { @@ -29,6 +31,8 @@ process.stdout.write = msg => { out += match[3]; } out += '\n'; + } else if (/(^|.*\s)(LOG|WARN|ERROR):\s([\S\s]*)/.test(msg)) { + // Nothing } else { out = msg; } diff --git a/test/polyfills.js b/test/polyfills.js index 1484dace75..59fbff16b0 100644 --- a/test/polyfills.js +++ b/test/polyfills.js @@ -80,7 +80,7 @@ function patchConsole(method) { window.console[method] = (...args) => { // @ts-ignore // eslint-disable-next-line no-undef - __karma__.log(method, serializeConsoleArgs(args)); + __karma__.log(method, ['__LOG_CUSTOM:' + serializeConsoleArgs(args)]); original.apply(window.console, args); }; } From faf6f9aeadda968f568d77e1b68010163a159bd1 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Sun, 24 Jan 2021 16:30:00 +0100 Subject: [PATCH 2/2] Test: Fix HTML elements logged as objects --- test/polyfills.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/polyfills.js b/test/polyfills.js index 59fbff16b0..e2f542b9f9 100644 --- a/test/polyfills.js +++ b/test/polyfills.js @@ -197,6 +197,10 @@ function serialize(value, mode, indent, seen) { return kl.cyan(`[Function: ${value.name || 'anonymous'}]`); } + if (value instanceof Element) { + return value.outerHTML; + } + seen.add(value); const props = Object.keys(value).map(key => { @@ -253,3 +257,4 @@ function serialize(value, mode, indent, seen) { // new Set([1, 2]), // new Map([[1, 2]]) // ); +// console.log(document.createElement('div'));