chore(test-runner): use test name as trace file name prefix (#9619)

This commit is contained in:
Max Schmitt 2021-11-01 18:15:19 +01:00 committed by GitHub
parent 13844a5b0a
commit 3c420a7cf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 26 deletions

View File

@ -22,6 +22,7 @@ import { rootTestType } from './testType';
import { createGuid, removeFolders } from 'playwright-core/lib/utils/utils';
import { GridClient } from 'playwright-core/lib/grid/gridClient';
import { Browser } from 'playwright-core';
import { sanitizeForFilePath } from './util';
export { expect } from './expect';
export const _baseTest: TestType<{}, {}> = rootTestType.test;
@ -254,7 +255,7 @@ export const test = _baseTest.extend<TestFixtures, WorkerAndFileFixtures>({
const traceAttachments: string[] = [];
const addTraceAttachment = () => {
const tracePath = testInfo.outputPath(`trace${traceAttachments.length ? '-' + traceAttachments.length : ''}.zip`);
const tracePath = testInfo.outputPath(`trace-${sanitizeForFilePath(testInfo.title)}${traceAttachments.length ? '-' + traceAttachments.length : ''}.zip`);
traceAttachments.push(tracePath);
testInfo.attachments.push({ name: 'trace', path: tracePath, contentType: 'application/zip' });
return tracePath;

View File

@ -199,27 +199,27 @@ test('should work with trace: on', async ({ runInlineTest }, testInfo) => {
expect(result.failed).toBe(5);
expect(listFiles(testInfo.outputPath('test-results'))).toEqual([
'artifacts-failing',
' trace.zip',
' trace-failing.zip',
'artifacts-own-context-failing',
' trace.zip',
' trace-own-context-failing.zip',
'artifacts-own-context-passing',
' trace.zip',
' trace-own-context-passing.zip',
'artifacts-passing',
' trace.zip',
' trace-passing.zip',
'artifacts-persistent-failing',
' trace.zip',
' trace-persistent-failing.zip',
'artifacts-persistent-passing',
' trace.zip',
' trace-persistent-passing.zip',
'artifacts-shared-shared-failing',
' trace.zip',
' trace-shared-failing.zip',
'artifacts-shared-shared-passing',
' trace.zip',
' trace-shared-passing.zip',
'artifacts-two-contexts',
' trace-1.zip',
' trace.zip',
' trace-two-contexts-1.zip',
' trace-two-contexts.zip',
'artifacts-two-contexts-failing',
' trace-1.zip',
' trace.zip',
' trace-two-contexts-failing-1.zip',
' trace-two-contexts-failing.zip',
'report.json',
]);
});
@ -237,16 +237,16 @@ test('should work with trace: retain-on-failure', async ({ runInlineTest }, test
expect(result.failed).toBe(5);
expect(listFiles(testInfo.outputPath('test-results'))).toEqual([
'artifacts-failing',
' trace.zip',
' trace-failing.zip',
'artifacts-own-context-failing',
' trace.zip',
' trace-own-context-failing.zip',
'artifacts-persistent-failing',
' trace.zip',
' trace-persistent-failing.zip',
'artifacts-shared-shared-failing',
' trace.zip',
' trace-shared-failing.zip',
'artifacts-two-contexts-failing',
' trace-1.zip',
' trace.zip',
' trace-two-contexts-failing-1.zip',
' trace-two-contexts-failing.zip',
'report.json',
]);
});
@ -264,16 +264,16 @@ test('should work with trace: on-first-retry', async ({ runInlineTest }, testInf
expect(result.failed).toBe(5);
expect(listFiles(testInfo.outputPath('test-results'))).toEqual([
'artifacts-failing-retry1',
' trace.zip',
' trace-failing.zip',
'artifacts-own-context-failing-retry1',
' trace.zip',
' trace-own-context-failing.zip',
'artifacts-persistent-failing-retry1',
' trace.zip',
' trace-persistent-failing.zip',
'artifacts-shared-shared-failing-retry1',
' trace.zip',
' trace-shared-failing.zip',
'artifacts-two-contexts-failing-retry1',
' trace-1.zip',
' trace.zip',
' trace-two-contexts-failing-1.zip',
' trace-two-contexts-failing.zip',
'report.json',
]);
});
@ -313,7 +313,7 @@ test('should stop tracing with trace: on-first-retry, when not retrying', async
expect(result.flaky).toBe(1);
expect(listFiles(testInfo.outputPath('test-results'))).toEqual([
'a-shared-flaky-retry1',
' trace.zip',
' trace-flaky.zip',
'report.json',
]);
});