Strip ANSI control sequences to clean up Axiom dashboard (#5934)

This commit is contained in:
Jace Browning
2025-03-21 13:54:56 -04:00
committed by GitHub
parent e00317f316
commit d443576c7c

View File

@ -2,6 +2,13 @@ import { readFileSync } from 'fs'
const data = readFileSync('./test-results/report.json', 'utf8') 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 // types, but was easier to store and run as normal js
// interface FailedTest { // interface FailedTest {
// name: string; // name: string;
@ -47,7 +54,7 @@ const processReport = (suites) => {
name: (name + ' -- ' + spec.title) + (test.title ? ` -- ${test.title}` : ''), name: (name + ' -- ' + spec.title) + (test.title ? ` -- ${test.title}` : ''),
status: result.status, status: result.status,
projectName: test.projectName, projectName: test.projectName,
error: result.error?.stack, error: stripAnsiEscapes(result.error?.stack),
}) })
} }
} }