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): trim full output path (#12239)

Dmitry Gozmanee0dd6ec7173
diff --git a/packages/playwright-test/src/testInfo.ts b/packages/playwright-test/src/testInfo.ts
index 7913a66b8e..a5ef6c0518 100644
--- a/packages/playwright-test/src/testInfo.ts
+++ b/packages/playwright-test/src/testInfo.ts
@@ -117,7 +117,7 @@ export class TestInfoImpl implements TestInfo {
const sanitizedRelativePath = relativeTestFilePath.replace(process.platform === 'win32' ? new RegExp('\\\\', 'g') : new RegExp('/', 'g'), '-');
const fullTitleWithoutSpec = test.titlePath().slice(1).join(' ') + (test._type === 'test' ? '' : '-worker' + this.workerIndex);
- let testOutputDir = sanitizedRelativePath + '-' + sanitizeForFilePath(trimLongString(fullTitleWithoutSpec));
+ let testOutputDir = trimLongString(sanitizedRelativePath + '-' + sanitizeForFilePath(fullTitleWithoutSpec));
if (uniqueProjectNamePathSegment)
testOutputDir += '-' + sanitizeForFilePath(uniqueProjectNamePathSegment);
if (this.retry)
diff --git a/tests/playwright-test/test-output-dir.spec.ts b/tests/playwright-test/test-output-dir.spec.ts
index c6a3b0892f..0c8f976408 100644
--- a/tests/playwright-test/test-output-dir.spec.ts
+++ b/tests/playwright-test/test-output-dir.spec.ts
@@ -431,7 +431,7 @@ test('should allow nonAscii characters in the output dir', async ({ runInlineTes
test('should allow shorten long output dirs characters in the output dir', async ({ runInlineTest }, testInfo) => {
const result = await runInlineTest({
- 'my-test.spec.js': `
+ 'very/deep/and/long/file/name/that/i/want/to/be/trimmed/my-test.spec.js': `
const { test } = pwt;
test.describe('this is a really long description that would be too long for a file path', () => {
test('and this is an even longer test name that just keeps going and going and we should shorten it', async ({}, testInfo) => {
@@ -441,7 +441,7 @@ test('should allow shorten long output dirs characters in the output dir', async
`,
});
const outputDir = result.output.split('\n').filter(x => x.startsWith('%%'))[0].slice('%%'.length);
- expect(outputDir).toBe(path.join(testInfo.outputDir, 'test-results', 'my-test-this-is-a-really-long-description-that-would-b-6d724--keeps-going-and-going-and-we-should-shorten-it'));
+ expect(outputDir).toBe(path.join(testInfo.outputDir, 'test-results', 'very-deep-and-long-file-name-that-i-want-to-be-99202--keeps-going-and-going-and-we-should-shorten-it'));
});
test('should not mangle double dashes', async ({ runInlineTest }, testInfo) => {