From c76f5294cea1b98fc667b677d042d28d3e4b5bb7 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Thu, 18 Jan 2024 14:23:12 -0800 Subject: [PATCH] fix: quote trace file path when printing error message (#29052) Fixes https://github.com/microsoft/playwright/issues/29039 --- packages/playwright/src/reporters/base.ts | 2 +- tests/playwright-test/reporter-attachment.spec.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/playwright/src/reporters/base.ts b/packages/playwright/src/reporters/base.ts index de5a26640f..2c6600f1b0 100644 --- a/packages/playwright/src/reporters/base.ts +++ b/packages/playwright/src/reporters/base.ts @@ -331,7 +331,7 @@ export function formatFailure(config: FullConfig, test: TestCase, options: {inde const packageManagerCommand = getPackageManagerExecCommand(); resultLines.push(colors.cyan(` Usage:`)); resultLines.push(''); - resultLines.push(colors.cyan(` ${packageManagerCommand} playwright show-trace ${relativePath}`)); + resultLines.push(colors.cyan(` ${packageManagerCommand} playwright show-trace "${relativePath}"`)); resultLines.push(''); } } else { diff --git a/tests/playwright-test/reporter-attachment.spec.ts b/tests/playwright-test/reporter-attachment.spec.ts index d761c0a4da..fd938be437 100644 --- a/tests/playwright-test/reporter-attachment.spec.ts +++ b/tests/playwright-test/reporter-attachment.spec.ts @@ -66,7 +66,7 @@ test('render trace attachment', async ({ runInlineTest }) => { test('one', async ({}, testInfo) => { testInfo.attachments.push({ name: 'trace', - path: testInfo.outputPath('trace.zip'), + path: testInfo.outputPath('my dir with space', 'trace.zip'), contentType: 'application/zip' }); expect(1).toBe(0); @@ -75,8 +75,8 @@ test('render trace attachment', async ({ runInlineTest }) => { }, { reporter: 'line' }); const text = result.output.replace(/\\/g, '/'); expect(text).toContain(' attachment #1: trace (application/zip) ─────────────────────────────────────────────────────────'); - expect(text).toContain(' test-results/a-one/trace.zip'); - expect(text).toContain('npx playwright show-trace test-results/a-one/trace.zip'); + expect(text).toContain(' test-results/a-one/my dir with space/trace.zip'); + expect(text).toContain('npx playwright show-trace "test-results/a-one/my dir with space/trace.zip"'); expect(text).toContain(' ────────────────────────────────────────────────────────────────────────────────────────────────'); expect(result.exitCode).toBe(1); });