Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix(test runner): dont mangle test names with multiple dashes (#10447)

Joel Einbinder20c0facfb9b9
diff --git a/packages/playwright-test/src/util.ts b/packages/playwright-test/src/util.ts
index 0d5274eb8a..11da8cc48b 100644
--- a/packages/playwright-test/src/util.ts
+++ b/packages/playwright-test/src/util.ts
@@ -141,7 +141,7 @@ export function expectType(receiver: any, type: string, matcherName: string) {
}
export function sanitizeForFilePath(s: string) {
- return s.replace(/[\x00-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+/g, '-');
+ return s.replace(/[\x00-\x2C\x2E-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+/g, '-');
}
export function addSuffixToFilePath(filePath: string, suffix: string, customExtension?: string, sanitize = false): string {
diff --git a/tests/playwright-test/test-output-dir.spec.ts b/tests/playwright-test/test-output-dir.spec.ts
index b47541da38..393f67773f 100644
--- a/tests/playwright-test/test-output-dir.spec.ts
+++ b/tests/playwright-test/test-output-dir.spec.ts
@@ -429,6 +429,19 @@ test('should allow nonAscii characters in the output dir', async ({ runInlineTes
expect(outputDir).toBe(path.join(testInfo.outputDir, 'test-results', 'my-test-こんにちは世界'));
});
+test('should not mangle double dashes', async ({ runInlineTest }, testInfo) => {
+ const result = await runInlineTest({
+ 'my--file.spec.js': `
+ const { test } = pwt;
+ test('my--test', async ({}, testInfo) => {
+ console.log('\\n%%' + testInfo.outputDir);
+ });
+ `,
+ });
+ const outputDir = result.output.split('\n').filter(x => x.startsWith('%%'))[0].slice('%%'.length);
+ expect(outputDir).toBe(path.join(testInfo.outputDir, 'test-results', 'my--file-my--test'));
+});
+
test('should allow include the describe name the output dir', async ({ runInlineTest }, testInfo) => {
const result = await runInlineTest({
'my-test.spec.js': `