chore: add quotes to the path only when necessary (#29057)

This is a follow-up to c76f5294ce
Reference https://github.com/microsoft/playwright/issues/29039
This commit is contained in:
Yury Semikhatsky 2024-01-19 10:27:15 -08:00 committed by GitHub
parent 6a15d43539
commit 674988c633
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 {
@ -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[] = [];