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

This commit is contained in:
Joel Einbinder 2021-11-24 19:36:38 -05:00 committed by GitHub
parent da02c2e2c8
commit 20c0facfb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -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 {

View File

@ -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': `