feat(blob): PLAYWRIGHT_BLOB_FILE_NAME env variable (#30530)

Reference https://github.com/microsoft/playwright/issues/30091
This commit is contained in:
Yury Semikhatsky 2024-04-25 09:45:38 -07:00 committed by GitHub
parent a2eb43b335
commit b074932a44
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 0 deletions

View File

@ -111,6 +111,8 @@ export class BlobReporter extends TeleReporterEmitter {
private _computeReportName(config: FullConfig) {
if (this._options.fileName)
return this._options.fileName;
if (process.env.PLAYWRIGHT_BLOB_FILE_NAME)
return process.env.PLAYWRIGHT_BLOB_FILE_NAME;
let reportName = 'report';
if (config.shard) {
const paddedNumber = `${config.shard.current}`.padStart(`${config.shard.total}`.length, '0');

View File

@ -1198,6 +1198,33 @@ test('support fileName option', async ({ runInlineTest, mergeReports }) => {
expect(reportFiles.sort()).toEqual(['report-one.zip', 'report-two.zip']);
});
test('support PLAYWRIGHT_BLOB_FILE_NAME environment variable', async ({ runInlineTest, mergeReports }) => {
const files = {
'playwright.config.ts': `
module.exports = {
reporter: 'blob',
projects: [
{ name: 'foo' },
]
};
`,
'a.test.js': `
import { test, expect } from '@playwright/test';
test('math 1 @smoke', async ({}) => {});
`,
'b.test.js': `
import { test, expect } from '@playwright/test';
test('math 1 @smoke', async ({}) => {});
`,
};
await runInlineTest(files, { shard: `1/2` }, { PLAYWRIGHT_BLOB_FILE_NAME: 'report-one.zip' });
await runInlineTest(files, { shard: `2/2` }, { PLAYWRIGHT_BLOB_FILE_NAME: 'report-two.zip', PWTEST_BLOB_DO_NOT_REMOVE: '1' });
const reportDir = test.info().outputPath('blob-report');
const reportFiles = await fs.promises.readdir(reportDir);
expect(reportFiles.sort()).toEqual(['report-one.zip', 'report-two.zip']);
});
test('keep projects with same name different bot name separate', async ({ runInlineTest, mergeReports, showReport, page }) => {
const files = (reportName: string) => ({
'playwright.config.ts': `