Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix(test-runner): use describe name in output dir (#8282)
Joel Einbindera8a3799e9de1
diff --git a/src/test/workerRunner.ts b/src/test/workerRunner.tsindex ad3edbba59..eaef35bcdd 100644--- a/src/test/workerRunner.ts+++ b/src/test/workerRunner.ts@@ -202,7 +202,8 @@ export class WorkerRunner extends EventEmitter {const baseOutputDir = (() => {const relativeTestFilePath = path.relative(this._project.config.testDir, test._requireFile.replace(/\.(spec|test)\.(js|ts|mjs)$/, ''));const sanitizedRelativePath = relativeTestFilePath.replace(process.platform === 'win32' ? new RegExp('\\\\', 'g') : new RegExp('/', 'g'), '-');- let testOutputDir = sanitizedRelativePath + '-' + sanitizeForFilePath(test.title);+ const fullTitleWithoutSpec = test.titlePath().slice(1).join(' ');+ let testOutputDir = sanitizedRelativePath + '-' + sanitizeForFilePath(fullTitleWithoutSpec);if (this._uniqueProjectNamePathSegment)testOutputDir += '-' + this._uniqueProjectNamePathSegment;if (retry)diff --git a/tests/playwright-test/playwright.artifacts.spec.ts b/tests/playwright-test/playwright.artifacts.spec.tsindex 2d51260d63..ba7c620fe3 100644--- a/tests/playwright-test/playwright.artifacts.spec.ts+++ b/tests/playwright-test/playwright.artifacts.spec.ts@@ -145,9 +145,9 @@ test('should work with screenshot: on', async ({ runInlineTest }, testInfo) => {' test-failed-1.png','artifacts-persistent-passing',' test-finished-1.png',- 'artifacts-shared-failing',+ 'artifacts-shared-shared-failing',' test-failed-1.png',- 'artifacts-shared-passing',+ 'artifacts-shared-shared-passing',' test-finished-1.png','artifacts-two-contexts',' test-finished-1.png',@@ -177,7 +177,7 @@ test('should work with screenshot: only-on-failure', async ({ runInlineTest }, t' test-failed-1.png','artifacts-persistent-failing',' test-failed-1.png',- 'artifacts-shared-failing',+ 'artifacts-shared-shared-failing',' test-failed-1.png','artifacts-two-contexts-failing',' test-failed-1.png',@@ -210,9 +210,9 @@ test('should work with trace: on', async ({ runInlineTest }, testInfo) => {' trace.zip','artifacts-persistent-passing',' trace.zip',- 'artifacts-shared-failing',+ 'artifacts-shared-shared-failing',' trace.zip',- 'artifacts-shared-passing',+ 'artifacts-shared-shared-passing',' trace.zip','artifacts-two-contexts',' trace-1.zip',@@ -242,7 +242,7 @@ test('should work with trace: retain-on-failure', async ({ runInlineTest }, test' trace.zip','artifacts-persistent-failing',' trace.zip',- 'artifacts-shared-failing',+ 'artifacts-shared-shared-failing',' trace.zip','artifacts-two-contexts-failing',' trace-1.zip',@@ -269,7 +269,7 @@ test('should work with trace: on-first-retry', async ({ runInlineTest }, testInf' trace.zip','artifacts-persistent-failing-retry1',' trace.zip',- 'artifacts-shared-failing-retry1',+ 'artifacts-shared-shared-failing-retry1',' trace.zip','artifacts-two-contexts-failing-retry1',' trace-1.zip',@@ -312,9 +312,9 @@ test('should stop tracing with trace: on-first-retry, when not retrying', asyncexpect(result.passed).toBe(1);expect(result.flaky).toBe(1);expect(listFiles(testInfo.outputPath('test-results'))).toEqual([- 'a-flaky-retry1',+ 'a-shared-flaky-retry1',' trace.zip',- 'a-no-tracing', // Empty dir created because of testInfo.outputPath() call.+ 'a-shared-no-tracing', // Empty dir created because of testInfo.outputPath() call.'report.json',]);});diff --git a/tests/playwright-test/test-output-dir.spec.ts b/tests/playwright-test/test-output-dir.spec.tsindex a67601cf41..5550ed00c3 100644--- a/tests/playwright-test/test-output-dir.spec.ts+++ b/tests/playwright-test/test-output-dir.spec.ts@@ -270,3 +270,18 @@ test('should allow nonAscii characters in the output dir', async ({ runInlineTesconst outputDir = result.output.split('\n').filter(x => x.startsWith('%%'))[0].slice('%%'.length);expect(outputDir).toBe(path.join(testInfo.outputDir, 'test-results', 'my-test-こんにちは世界'));});++test('should allow include the describe name the output dir', async ({ runInlineTest }, testInfo) => {+ const result = await runInlineTest({+ 'my-test.spec.js': `+ const { test } = pwt;+ test.describe('hello', () => {+ test('world', 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-test-hello-world'));+});