diff --git a/packages/playwright/src/isomorphic/teleReceiver.ts b/packages/playwright/src/isomorphic/teleReceiver.ts index f33041a97f..4ea983ea02 100644 --- a/packages/playwright/src/isomorphic/teleReceiver.ts +++ b/packages/playwright/src/isomorphic/teleReceiver.ts @@ -69,6 +69,7 @@ export type JsonTestCase = { retries: number; tags?: string[]; repeatEachIndex: number; + annotations?: { type: string, description?: string }[]; }; export type JsonTestEnd = { @@ -391,6 +392,7 @@ export class TeleReporterReceiver { test.location = this._absoluteLocation(payload.location); test.retries = payload.retries; test.tags = payload.tags ?? []; + test.annotations = payload.annotations ?? []; return test; } diff --git a/packages/playwright/src/reporters/teleEmitter.ts b/packages/playwright/src/reporters/teleEmitter.ts index 59ad776a38..d6cfb21320 100644 --- a/packages/playwright/src/reporters/teleEmitter.ts +++ b/packages/playwright/src/reporters/teleEmitter.ts @@ -208,6 +208,7 @@ export class TeleReporterEmitter implements ReporterV2 { retries: test.retries, tags: test.tags, repeatEachIndex: test.repeatEachIndex, + annotations: test.annotations, }; } diff --git a/tests/playwright-test/reporter-blob.spec.ts b/tests/playwright-test/reporter-blob.spec.ts index 2ddfcfcc96..5e1cfef223 100644 --- a/tests/playwright-test/reporter-blob.spec.ts +++ b/tests/playwright-test/reporter-blob.spec.ts @@ -1752,3 +1752,46 @@ test('open blob-1.42', async ({ runInlineTest, mergeReports }) => { > webkit > example.spec.ts > test 6 > webkit > example.spec.ts > describe 1 > test 5`); }); + +test('preserve static annotations when tests did not run', async ({ runInlineTest, mergeReports, showReport, page }) => { + test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/30260' }); + const reportDir = test.info().outputPath('blob-report'); + const files = { + 'playwright.config.ts': ` + module.exports = { + reporter: 'blob', + projects: [ + { name: 'setup', testMatch: 'setup.js' }, + { name: 'tests', testMatch: /.*test.js/, dependencies: ['setup'] }, + ] + }; + `, + 'setup.js': ` + import { test, expect } from '@playwright/test'; + test('setup', { annotation: [{ type: "sample", description: "uno" }] }, async ({}) => { + expect(1).toBe(2); + }); + `, + 'a.test.js': ` + import { test, expect } from '@playwright/test'; + test('first', { annotation: [{ type: "sample", description: "uno" }] }, async ({}) => {}); + test.skip('second', { annotation: [{ type: "sample", description: "dos" }] }, async ({}) => {}); + ` + }; + await runInlineTest(files); + const { exitCode } = await mergeReports(reportDir, { 'PW_TEST_HTML_REPORT_OPEN': 'never' }, { additionalArgs: ['--reporter', 'html'] }); + expect(exitCode).toBe(0); + await showReport(); + // Check first annotation. + { + await page.getByRole('link', { name: 'first' }).click(); + await expect(page.getByText('sample: uno')).toBeVisible(); + await page.goBack(); + } + // Check second annotation. + { + await page.getByRole('link', { name: 'second' }).click(); + await expect(page.getByText('sample: dos')).toBeVisible(); + await page.goBack(); + } +});