Skip to content

Commit 20c0fac

Browse files
fix(test runner): dont mangle test names with multiple dashes (microsoft#10447)
1 parent da02c2e commit 20c0fac

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

packages/playwright-test/src/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export function expectType(receiver: any, type: string, matcherName: string) {
141141
}
142142

143143
export function sanitizeForFilePath(s: string) {
144-
return s.replace(/[\x00-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+/g, '-');
144+
return s.replace(/[\x00-\x2C\x2E-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+/g, '-');
145145
}
146146

147147
export function addSuffixToFilePath(filePath: string, suffix: string, customExtension?: string, sanitize = false): string {

tests/playwright-test/test-output-dir.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,19 @@ test('should allow nonAscii characters in the output dir', async ({ runInlineTes
429429
expect(outputDir).toBe(path.join(testInfo.outputDir, 'test-results', 'my-test-こんにちは世界'));
430430
});
431431

432+
test('should not mangle double dashes', async ({ runInlineTest }, testInfo) => {
433+
const result = await runInlineTest({
434+
'my--file.spec.js': `
435+
const { test } = pwt;
436+
test('my--test', async ({}, testInfo) => {
437+
console.log('\\n%%' + testInfo.outputDir);
438+
});
439+
`,
440+
});
441+
const outputDir = result.output.split('\n').filter(x => x.startsWith('%%'))[0].slice('%%'.length);
442+
expect(outputDir).toBe(path.join(testInfo.outputDir, 'test-results', 'my--file-my--test'));
443+
});
444+
432445
test('should allow include the describe name the output dir', async ({ runInlineTest }, testInfo) => {
433446
const result = await runInlineTest({
434447
'my-test.spec.js': `

0 commit comments

Comments
 (0)