From 0c25d293463ba1ed78c57557504e2121c2d745eb Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Thu, 1 Aug 2024 14:52:50 -0700 Subject: [PATCH 01/17] fix: Disable color output --- src/playwright-runner.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/playwright-runner.ts b/src/playwright-runner.ts index dbd21c18..db0d8eef 100644 --- a/src/playwright-runner.ts +++ b/src/playwright-runner.ts @@ -345,7 +345,7 @@ async function runPlaywright( ...suite.env, PLAYWRIGHT_JUNIT_OUTPUT_NAME: runCfg.junitFile, SAUCE_REPORT_OUTPUT_NAME: runCfg.sauceReportFile, - FORCE_COLOR: '0', + FORCE_COLOR: 'false', SAUCE_WEB_ASSETS_DIR: runCfg.webAssetsDir, }; From bb3bef72a9cb8957e6dc20d0d98f11f22bde64d3 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Tue, 6 Aug 2024 11:33:14 -0700 Subject: [PATCH 02/17] fix: Update regex for removing ANSI colors output --- src/playwright-recorder.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/playwright-recorder.ts b/src/playwright-recorder.ts index 8164f0e4..a328268a 100644 --- a/src/playwright-recorder.ts +++ b/src/playwright-recorder.ts @@ -4,7 +4,11 @@ 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( + // eslint-disable-next-line no-control-regex + '[\\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. From 6121d0a78429fb85ae9e896c4fd47dfd7f765f26 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Tue, 6 Aug 2024 11:35:01 -0700 Subject: [PATCH 03/17] revert FORCE_COLOR update --- src/playwright-runner.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/playwright-runner.ts b/src/playwright-runner.ts index db0d8eef..dbd21c18 100644 --- a/src/playwright-runner.ts +++ b/src/playwright-runner.ts @@ -345,7 +345,7 @@ async function runPlaywright( ...suite.env, PLAYWRIGHT_JUNIT_OUTPUT_NAME: runCfg.junitFile, SAUCE_REPORT_OUTPUT_NAME: runCfg.sauceReportFile, - FORCE_COLOR: 'false', + FORCE_COLOR: '0', SAUCE_WEB_ASSETS_DIR: runCfg.webAssetsDir, }; From 0b94e2398dd653184fff789c9e1acb8e1e57cab2 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Tue, 6 Aug 2024 12:54:31 -0700 Subject: [PATCH 04/17] strip stderr as well --- src/playwright-recorder.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/playwright-recorder.ts b/src/playwright-recorder.ts index a328268a..5773776f 100644 --- a/src/playwright-recorder.ts +++ b/src/playwright-recorder.ts @@ -32,7 +32,7 @@ export function playwrightRecorder() { child.stdout.pipe(process.stdout); child.stderr.pipe(process.stderr); child.stdout.pipe(stripAsciiTransform).pipe(ws); - child.stderr.pipe(ws); + child.stderr.pipe(stripAsciiTransform).pipe(ws); child.on('exit', (exitCode) => { ws.end(); From ad27faa55915db2408ebd1955d74e989078e1b06 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Tue, 6 Aug 2024 14:31:44 -0700 Subject: [PATCH 05/17] also strip process.stdout --- src/playwright-recorder.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/playwright-recorder.ts b/src/playwright-recorder.ts index 5773776f..1de93415 100644 --- a/src/playwright-recorder.ts +++ b/src/playwright-recorder.ts @@ -29,10 +29,9 @@ 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(stripAsciiTransform).pipe(ws); child.on('exit', (exitCode) => { ws.end(); From 286c6c153d635970bc42b1a09f4e791e4449bd46 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Tue, 6 Aug 2024 14:38:47 -0700 Subject: [PATCH 06/17] fix typo --- src/playwright-recorder.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/playwright-recorder.ts b/src/playwright-recorder.ts index 1de93415..ac80590a 100644 --- a/src/playwright-recorder.ts +++ b/src/playwright-recorder.ts @@ -30,8 +30,9 @@ export function playwrightRecorder() { ]); child.stdout.pipe(stripAsciiTransform).pipe(process.stdout); - child.stderr.pipe(process.stderr); child.stdout.pipe(stripAsciiTransform).pipe(ws); + child.stderr.pipe(process.stderr); + child.stderr.pipe(ws); child.on('exit', (exitCode) => { ws.end(); From 9d8f7b684bcdd9443545ebe2941c52fcde4262e6 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Tue, 6 Aug 2024 14:46:33 -0700 Subject: [PATCH 07/17] test output --- src/playwright-recorder.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/playwright-recorder.ts b/src/playwright-recorder.ts index ac80590a..d9c57898 100644 --- a/src/playwright-recorder.ts +++ b/src/playwright-recorder.ts @@ -30,9 +30,9 @@ export function playwrightRecorder() { ]); child.stdout.pipe(stripAsciiTransform).pipe(process.stdout); - child.stdout.pipe(stripAsciiTransform).pipe(ws); + //child.stdout.pipe(stripAsciiTransform).pipe(ws); child.stderr.pipe(process.stderr); - child.stderr.pipe(ws); + //child.stderr.pipe(ws); child.on('exit', (exitCode) => { ws.end(); From ae0e6a64c4dc204ea14c69cc494318d4cb62c088 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Tue, 6 Aug 2024 15:03:28 -0700 Subject: [PATCH 08/17] test output file --- src/playwright-recorder.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/playwright-recorder.ts b/src/playwright-recorder.ts index d9c57898..0afa51f3 100644 --- a/src/playwright-recorder.ts +++ b/src/playwright-recorder.ts @@ -12,7 +12,7 @@ const escapeSequenceRegex = new RegExp( 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'), { + const ws = fs.createWriteStream(path.join(process.cwd(), 'console2.log'), { flags: 'w+', mode: 0o644, }); @@ -30,8 +30,8 @@ export function playwrightRecorder() { ]); child.stdout.pipe(stripAsciiTransform).pipe(process.stdout); - //child.stdout.pipe(stripAsciiTransform).pipe(ws); child.stderr.pipe(process.stderr); + //child.stdout.pipe(ws); //child.stderr.pipe(ws); child.on('exit', (exitCode) => { From 8ee1b4fb5a8093a072766d8a6c12f9946822cfc1 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Tue, 6 Aug 2024 15:24:12 -0700 Subject: [PATCH 09/17] what if I disable stdout/stderr? --- src/playwright-recorder.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/playwright-recorder.ts b/src/playwright-recorder.ts index 0afa51f3..7a7ce835 100644 --- a/src/playwright-recorder.ts +++ b/src/playwright-recorder.ts @@ -12,7 +12,7 @@ const escapeSequenceRegex = new RegExp( export function playwrightRecorder() { // console.log is saved out of reportsDir since it is cleared on startup. - const ws = fs.createWriteStream(path.join(process.cwd(), 'console2.log'), { + const ws = fs.createWriteStream(path.join(process.cwd(), 'console.log'), { flags: 'w+', mode: 0o644, }); @@ -29,10 +29,10 @@ export function playwrightRecorder() { ...process.argv.slice(2), ]); - child.stdout.pipe(stripAsciiTransform).pipe(process.stdout); - child.stderr.pipe(process.stderr); - //child.stdout.pipe(ws); - //child.stderr.pipe(ws); + //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(); From 57f27de66736e573d28bb6ef32a46ddb95705497 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Tue, 6 Aug 2024 16:05:53 -0700 Subject: [PATCH 10/17] test different log file name --- src/playwright-recorder.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/playwright-recorder.ts b/src/playwright-recorder.ts index 7a7ce835..19855fa0 100644 --- a/src/playwright-recorder.ts +++ b/src/playwright-recorder.ts @@ -12,7 +12,7 @@ const escapeSequenceRegex = new RegExp( 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'), { + const ws = fs.createWriteStream(path.join(process.cwd(), 'console2.log'), { flags: 'w+', mode: 0o644, }); @@ -29,9 +29,9 @@ export function playwrightRecorder() { ...process.argv.slice(2), ]); - //child.stdout.pipe(stripAsciiTransform).pipe(process.stdout); - //child.stderr.pipe(process.stderr); - child.stdout.pipe(stripAsciiTransform).pipe(ws); + child.stdout.pipe(stripAsciiTransform).pipe(process.stdout); + child.stderr.pipe(process.stderr); + child.stdout.pipe(ws); child.stderr.pipe(ws); child.on('exit', (exitCode) => { From d5f73c2e15f046c01a0e46d904259f15a9b215ba Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Tue, 6 Aug 2024 16:25:55 -0700 Subject: [PATCH 11/17] put console log under assets folder --- src/playwright-recorder.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/playwright-recorder.ts b/src/playwright-recorder.ts index 19855fa0..8811b224 100644 --- a/src/playwright-recorder.ts +++ b/src/playwright-recorder.ts @@ -12,10 +12,13 @@ const escapeSequenceRegex = new RegExp( export function playwrightRecorder() { // console.log is saved out of reportsDir since it is cleared on startup. - const ws = fs.createWriteStream(path.join(process.cwd(), 'console2.log'), { - flags: 'w+', - mode: 0o644, - }); + const ws = fs.createWriteStream( + path.join(process.cwd(), '__assets__', 'console2.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 From 3b3a91bd9543495267fc389ee6f9dd75f27c84f5 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Tue, 6 Aug 2024 20:32:21 -0700 Subject: [PATCH 12/17] remove debug code --- src/playwright-recorder.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/playwright-recorder.ts b/src/playwright-recorder.ts index 8811b224..1d9f8234 100644 --- a/src/playwright-recorder.ts +++ b/src/playwright-recorder.ts @@ -11,9 +11,8 @@ const escapeSequenceRegex = new RegExp( ); export function playwrightRecorder() { - // console.log is saved out of reportsDir since it is cleared on startup. const ws = fs.createWriteStream( - path.join(process.cwd(), '__assets__', 'console2.log'), + path.join(process.cwd(), '__assets__', 'console.log'), { flags: 'w+', mode: 0o644, From 588b31583cdda0683ec690aa8ef20f539c2d800c Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Tue, 6 Aug 2024 20:43:12 -0700 Subject: [PATCH 13/17] fix filepath --- src/playwright-recorder.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/playwright-recorder.ts b/src/playwright-recorder.ts index 1d9f8234..525e3078 100644 --- a/src/playwright-recorder.ts +++ b/src/playwright-recorder.ts @@ -11,13 +11,14 @@ const escapeSequenceRegex = new RegExp( ); export function playwrightRecorder() { - const ws = fs.createWriteStream( - path.join(process.cwd(), '__assets__', 'console.log'), - { - flags: 'w+', - mode: 0o644, - }, - ); + const assetsPath = path.join(process.cwd(), '__assets__'); + if (!fs.existsSync(assetsPath)) { + fs.mkdirSync(assetsPath); + } + const ws = fs.createWriteStream(path.join(assetsPath, '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 From a0b846e8c11f96e1d87f4abe672ce29fef7a29a7 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Wed, 7 Aug 2024 09:48:50 -0700 Subject: [PATCH 14/17] let spawn error --- src/playwright-recorder.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/playwright-recorder.ts b/src/playwright-recorder.ts index 525e3078..b5616c4c 100644 --- a/src/playwright-recorder.ts +++ b/src/playwright-recorder.ts @@ -15,7 +15,7 @@ export function playwrightRecorder() { if (!fs.existsSync(assetsPath)) { fs.mkdirSync(assetsPath); } - const ws = fs.createWriteStream(path.join(assetsPath, 'console.log'), { + const ws = fs.createWriteStream(path.join(assetsPath, 'console2.log'), { flags: 'w+', mode: 0o644, }); @@ -28,7 +28,7 @@ export function playwrightRecorder() { const [nodeBin] = process.argv; const child = childProcess.spawn(nodeBin, [ - path.join(__dirname, 'playwright-runner.js'), + path.join(__dirname, 'playwright-runer.js'), ...process.argv.slice(2), ]); From 3138698ba5c45c1bc339bf1d8e65960e481cf305 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Wed, 7 Aug 2024 10:14:45 -0700 Subject: [PATCH 15/17] revert debug --- src/playwright-recorder.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/playwright-recorder.ts b/src/playwright-recorder.ts index b5616c4c..1e7c7566 100644 --- a/src/playwright-recorder.ts +++ b/src/playwright-recorder.ts @@ -28,7 +28,7 @@ export function playwrightRecorder() { const [nodeBin] = process.argv; const child = childProcess.spawn(nodeBin, [ - path.join(__dirname, 'playwright-runer.js'), + path.join(__dirname, 'playwright-runner.js'), ...process.argv.slice(2), ]); From 198697c51ffad80523a8db235d3e523294e67049 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Wed, 7 Aug 2024 10:51:55 -0700 Subject: [PATCH 16/17] bump package --- package-lock.json | 9 +++++---- package.json | 2 +- src/playwright-recorder.ts | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) 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 1e7c7566..525e3078 100644 --- a/src/playwright-recorder.ts +++ b/src/playwright-recorder.ts @@ -15,7 +15,7 @@ export function playwrightRecorder() { if (!fs.existsSync(assetsPath)) { fs.mkdirSync(assetsPath); } - const ws = fs.createWriteStream(path.join(assetsPath, 'console2.log'), { + const ws = fs.createWriteStream(path.join(assetsPath, 'console.log'), { flags: 'w+', mode: 0o644, }); From 2baf0872e6e8bdf9d0840a41279e163528aef02d Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Wed, 7 Aug 2024 14:20:52 -0700 Subject: [PATCH 17/17] remove console.log directly --- src/playwright-recorder.ts | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/playwright-recorder.ts b/src/playwright-recorder.ts index 525e3078..ba86aa2c 100644 --- a/src/playwright-recorder.ts +++ b/src/playwright-recorder.ts @@ -1,24 +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( - // eslint-disable-next-line no-control-regex '[\\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() { - const assetsPath = path.join(process.cwd(), '__assets__'); - if (!fs.existsSync(assetsPath)) { - fs.mkdirSync(assetsPath); - } - const ws = fs.createWriteStream(path.join(assetsPath, '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 @@ -34,11 +24,8 @@ export function playwrightRecorder() { child.stdout.pipe(stripAsciiTransform).pipe(process.stdout); child.stderr.pipe(process.stderr); - child.stdout.pipe(ws); - child.stderr.pipe(ws); child.on('exit', (exitCode) => { - ws.end(); process.exit(exitCode ?? 1); }); }