Skip to content

Commit

Permalink
chore: add quotes to the path only when necessary (#29057)
Browse files Browse the repository at this point in the history
This is a follow-up to c76f529
Reference #29039
  • Loading branch information
yury-s authored Jan 19, 2024
1 parent 6a15d43 commit 674988c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/playwright/src/reporters/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ${quotePathIfNeeded(relativePath)}`));
resultLines.push('');
}
} else {
Expand Down Expand Up @@ -373,6 +373,12 @@ export function formatFailure(config: FullConfig, test: TestCase, options: {inde
};
}

function quotePathIfNeeded(path: string): string {
if (/\W/.test(path))
return `"${path}"`;
return path;
}

export function formatResultFailure(test: TestCase, result: TestResult, initialIndent: string, highlightCode: boolean): ErrorDetails[] {
const errorDetails: ErrorDetails[] = [];

Expand Down

0 comments on commit 674988c

Please sign in to comment.