From 4e101e2fd9151a9e0a41f8284feba30b32e1a77a Mon Sep 17 00:00:00 2001 From: Thodoris Greasidis Date: Sat, 13 Jul 2024 17:41:14 +0300 Subject: [PATCH] Omit unicode control character escapes from test logs Change-type: patch --- tests/helpers.ts | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/tests/helpers.ts b/tests/helpers.ts index 21a6ffa4..dddf112e 100644 --- a/tests/helpers.ts +++ b/tests/helpers.ts @@ -64,18 +64,24 @@ export function filterCliOutputForTests({ err: string[]; out: string[]; }): { err: string[]; out: string[] } { + // eslint-disable-next-line no-control-regex + const unicodeCharacterEscapesRegex = /\u001b\[3[0-9]m/g; return { - err: err.filter( - (line: string) => - line && - !line.match(/\[debug\]/i) && - // TODO stop this warning message from appearing when running - // sdk.setSharedOptions multiple times in the same process - !line.startsWith('Shared SDK options') && - !line.startsWith('WARN: disabling Sentry.io error reporting') && - !matchesNodeEngineVersionWarn(line), - ), - out: out.filter((line: string) => line && !line.match(/\[debug\]/i)), + err: err + .map((line) => line.replaceAll(unicodeCharacterEscapesRegex, '')) + .filter( + (line: string) => + line && + !line.match(/\[debug\]/i) && + // TODO stop this warning message from appearing when running + // sdk.setSharedOptions multiple times in the same process + !line.startsWith('Shared SDK options') && + !line.startsWith('WARN: disabling Sentry.io error reporting') && + !matchesNodeEngineVersionWarn(line), + ), + out: out + .map((line) => line.replaceAll(unicodeCharacterEscapesRegex, '')) + .filter((line) => line && !line.match(/\[debug\]/i)), }; }