diff --git a/packages/playwright/src/reporters/blob.ts b/packages/playwright/src/reporters/blob.ts index 1c95658f6c..20135cb5f3 100644 --- a/packages/playwright/src/reporters/blob.ts +++ b/packages/playwright/src/reporters/blob.ts @@ -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'); diff --git a/tests/playwright-test/reporter-blob.spec.ts b/tests/playwright-test/reporter-blob.spec.ts index 5e1cfef223..eb62661d95 100644 --- a/tests/playwright-test/reporter-blob.spec.ts +++ b/tests/playwright-test/reporter-blob.spec.ts @@ -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': `