diff --git a/package-lock.json b/package-lock.json index b4106756..87362fff 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "MIT", "dependencies": { "@playwright/test": "1.45.2", - "@saucelabs/playwright-reporter": "1.2.1", + "@saucelabs/playwright-reporter": "1.2.2", "@saucelabs/testcomposer": "3.0.0", "dotenv": "16.4.5", "lodash": "4.17.21", @@ -2966,9 +2966,10 @@ } }, "node_modules/@saucelabs/playwright-reporter": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@saucelabs/playwright-reporter/-/playwright-reporter-1.2.1.tgz", - "integrity": "sha512-cwSFi8ts2yOBHU0A3BNeV/4f6eaZhyYZXszmnDijWI6q/uB7dhmQKZFvQ9SYmF0iYerETcD3PtO8y8w8rIAA9Q==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@saucelabs/playwright-reporter/-/playwright-reporter-1.2.2.tgz", + "integrity": "sha512-Y10G4RjVCgrDhg/dEcGRBpuWXdgbbzxP6I+EfMznxu4HYxpQf7gq7RSNpNEnbNoieAbGmtU8SwkY0QgIoqfnNw==", + "license": "MIT", "dependencies": { "@saucelabs/sauce-json-reporter": "4.1.0", "@saucelabs/testcomposer": "3.0.0", diff --git a/package.json b/package.json index 24592988..49c0906a 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "homepage": "https://github.com/saucelabs/sauce-playwright-runner", "dependencies": { "@playwright/test": "1.45.2", - "@saucelabs/playwright-reporter": "1.2.1", + "@saucelabs/playwright-reporter": "1.2.2", "@saucelabs/testcomposer": "3.0.0", "dotenv": "16.4.5", "lodash": "4.17.21", diff --git a/src/playwright-recorder.ts b/src/playwright-recorder.ts index 8164f0e4..ba86aa2c 100644 --- a/src/playwright-recorder.ts +++ b/src/playwright-recorder.ts @@ -1,17 +1,14 @@ -import * as fs from 'node:fs'; import * as path from 'node:path'; import { Transform } from 'node:stream'; import * as childProcess from 'node:child_process'; import * as process from 'node:process'; -const escapeSequenceRegex = new RegExp('[\\u001b]\\[2K|[\\u001b]\\[0G', 'g'); +const escapeSequenceRegex = 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 playwrightRecorder() { - // console.log is saved out of reportsDir since it is cleared on startup. - const ws = fs.createWriteStream(path.join(process.cwd(), 'console.log'), { - flags: 'w+', - mode: 0o644, - }); const stripAsciiTransform = new Transform({ transform(chunk, _, callback) { // list reporter uses escape codes to rewrite lines, strip them to make console output more readable @@ -25,13 +22,10 @@ export function playwrightRecorder() { ...process.argv.slice(2), ]); - child.stdout.pipe(process.stdout); + child.stdout.pipe(stripAsciiTransform).pipe(process.stdout); child.stderr.pipe(process.stderr); - child.stdout.pipe(stripAsciiTransform).pipe(ws); - child.stderr.pipe(ws); child.on('exit', (exitCode) => { - ws.end(); process.exit(exitCode ?? 1); }); }