From d443576c7ccc143fec18d675fba709f2adff4c14 Mon Sep 17 00:00:00 2001 From: Jace Browning Date: Fri, 21 Mar 2025 13:54:56 -0400 Subject: [PATCH] Strip ANSI control sequences to clean up Axiom dashboard (#5934) --- playwrightProcess.mjs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/playwrightProcess.mjs b/playwrightProcess.mjs index c614e38fd..5a640ce01 100644 --- a/playwrightProcess.mjs +++ b/playwrightProcess.mjs @@ -2,6 +2,13 @@ import { readFileSync } from 'fs' const data = readFileSync('./test-results/report.json', 'utf8') +// We need this until Playwright's JSON reporter supports `stripANSIControlSequences` +// https://github.com/microsoft/playwright/issues/33670#issuecomment-2487941649 +const ansiRegex = new RegExp('([\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~])))', 'g'); +export function stripAnsiEscapes(str) { + return str ? str.replace(ansiRegex, '') : ''; +} + // types, but was easier to store and run as normal js // interface FailedTest { // name: string; @@ -47,7 +54,7 @@ const processReport = (suites) => { name: (name + ' -- ' + spec.title) + (test.title ? ` -- ${test.title}` : ''), status: result.status, projectName: test.projectName, - error: result.error?.stack, + error: stripAnsiEscapes(result.error?.stack), }) } }