Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: blob report project suffix (#23212)

Yury Semikhatsky10b7cb397924
diff --git a/.github/workflows/tests_primary.yml b/.github/workflows/tests_primary.yml
index e1bfaa9b4e..e3f3655ae3 100644
--- a/.github/workflows/tests_primary.yml
+++ b/.github/workflows/tests_primary.yml
@@ -53,6 +53,7 @@ jobs:
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test -- --project=${{ matrix.browser }}
env:
PWTEST_BLOB_REPORT: 1
+ PWTEST_BLOB_SUFFIX: "-${{ matrix.os }}-node${{ matrix.node-version }}"
- run: node tests/config/checkCoverage.js ${{ matrix.browser }}
- run: ./utils/upload_flakiness_dashboard.sh ./test-results/report.json
if: always()
@@ -141,10 +142,12 @@ jobs:
- run: npm run ttest -- --shard ${{ matrix.shard }}
env:
PWTEST_BLOB_REPORT: 1
+ PWTEST_BLOB_SUFFIX: "-${{ matrix.os }}-node${{ matrix.node-version }}"
if: matrix.os != 'ubuntu-latest'
- run: xvfb-run npm run ttest -- --shard ${{ matrix.shard }}
env:
PWTEST_BLOB_REPORT: 1
+ PWTEST_BLOB_SUFFIX: "-${{ matrix.os }}-node${{ matrix.node-version }}"
if: matrix.os == 'ubuntu-latest'
- run: ./utils/upload_flakiness_dashboard.sh ./test-results/report.json
if: always()
diff --git a/.github/workflows/tests_secondary.yml b/.github/workflows/tests_secondary.yml
index 559fd92f45..286e96196e 100644
--- a/.github/workflows/tests_secondary.yml
+++ b/.github/workflows/tests_secondary.yml
@@ -204,6 +204,7 @@ jobs:
PWTEST_TRACE: 1
PWTEST_CHANNEL: ${{ matrix.channel }}
PWTEST_BLOB_REPORT: 1
+ PWTEST_BLOB_SUFFIX: "-${{ matrix.channel }}"
- run: ./utils/upload_flakiness_dashboard.sh ./test-results/report.json
if: always()
shell: bash
diff --git a/packages/playwright-test/src/reporters/blob.ts b/packages/playwright-test/src/reporters/blob.ts
index 7b0d310a68..3edcbce30a 100644
--- a/packages/playwright-test/src/reporters/blob.ts
+++ b/packages/playwright-test/src/reporters/blob.ts
@@ -66,6 +66,11 @@ export class BlobReporter extends TeleReporterEmitter {
]);
}
+ override _serializeProjectName(name: string): string {
+ const suffix = process.env.PWTEST_BLOB_SUFFIX;
+ return name + (suffix ? suffix : '');
+ }
+
override _serializeAttachments(attachments: TestResult['attachments']): TestResult['attachments'] {
return attachments.map(attachment => {
if (!attachment.path || !fs.statSync(attachment.path).isFile())
diff --git a/packages/playwright-test/src/reporters/teleEmitter.ts b/packages/playwright-test/src/reporters/teleEmitter.ts
index b65c3e57d1..48b32bdeab 100644
--- a/packages/playwright-test/src/reporters/teleEmitter.ts
+++ b/packages/playwright-test/src/reporters/teleEmitter.ts
@@ -144,7 +144,7 @@ export class TeleReporterEmitter implements Reporter {
const report: JsonProject = {
id: projectIds.get(project)!,
metadata: project.metadata,
- name: project.name,
+ name: this._serializeProjectName(project.name),
outputDir: this._relativePath(project.outputDir),
repeatEach: project.repeatEach,
retries: project.retries,
@@ -164,6 +164,10 @@ export class TeleReporterEmitter implements Reporter {
return report;
}
+ _serializeProjectName(name: string): string {
+ return name;
+ }
+
private _serializeSuite(suite: Suite): JsonSuite {
const result = {
type: suite._type,
diff --git a/tests/playwright-test/playwright-test-fixtures.ts b/tests/playwright-test/playwright-test-fixtures.ts
index 033cee5e4c..1b4172e0fa 100644
--- a/tests/playwright-test/playwright-test-fixtures.ts
+++ b/tests/playwright-test/playwright-test-fixtures.ts
@@ -227,6 +227,7 @@ export function cleanEnv(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv {
PW_TEST_REPORTER_WS_ENDPOINT: undefined,
PW_TEST_SOURCE_TRANSFORM: undefined,
PW_TEST_SOURCE_TRANSFORM_SCOPE: undefined,
+ PWTEST_BLOB_SUFFIX: undefined,
TEST_WORKER_INDEX: undefined,
TEST_PARLLEL_INDEX: undefined,
NODE_OPTIONS: undefined,
diff --git a/tests/playwright-test/reporter-blob.spec.ts b/tests/playwright-test/reporter-blob.spec.ts
index 11224f32eb..8c54d8e801 100644
--- a/tests/playwright-test/reporter-blob.spec.ts
+++ b/tests/playwright-test/reporter-blob.spec.ts
@@ -898,4 +898,44 @@ test('preserve steps in html report', async ({ runInlineTest, mergeReports, show
await expect(page.getByText('— tests/a.test.js:7')).toBeVisible();
await page.getByText('my step').click();
await expect(page.getByText('expect.toBe')).toBeVisible();
-});
\ No newline at end of file
+});
+
+test('custom project suffix', async ({ runInlineTest, mergeReports }) => {
+ test.slow();
+ const reportDir = test.info().outputPath('blob-report');
+ const files = {
+ 'echo-reporter.js': `
+ import fs from 'fs';
+
+ class EchoReporter {
+ onBegin(config, suite) {
+ const projects = suite.suites.map(s => s.project().name);
+ console.log('projects:', projects);
+ }
+ }
+ module.exports = EchoReporter;
+ `,
+ 'playwright.config.ts': `
+ module.exports = {
+ retries: 1,
+ reporter: 'blob',
+ projects: [
+ { name: 'foo' },
+ { name: 'bar' },
+ ]
+ };
+ `,
+ 'a.test.js': `
+ import { test, expect } from '@playwright/test';
+ test('math 1', async ({}) => {
+ expect(1 + 1).toBe(2);
+ });
+ `,
+ };
+
+ await runInlineTest(files, undefined, { PWTEST_BLOB_SUFFIX: '-suffix' });
+
+ const { exitCode, output } = await mergeReports(reportDir, {}, { additionalArgs: ['--reporter', test.info().outputPath('echo-reporter.js')] });
+ expect(exitCode).toBe(0);
+ expect(output).toContain(`projects: [ 'foo-suffix', 'bar-suffix' ]`);
+});