Skip to content

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

chore: do not show other metadata in html report (#35001)

Pavel Feldmanee2a5264ad89
diff --git a/docs/src/release-notes-js.md b/docs/src/release-notes-js.md
index c0f6d550dd..2f3316c730 100644
--- a/docs/src/release-notes-js.md
+++ b/docs/src/release-notes-js.md
@@ -71,8 +71,6 @@ import LiteYouTube from '@site/src/components/LiteYouTube';
});
```
-* HTML reporter now shows the contents of [`property: TestConfig.metadata`].
-
### Miscellaneous
* New option `contrast` for methods [`method: Page.emulateMedia`] and [`method: Browser.newContext`] allows to emulate the `prefers-contrast` media feature.
diff --git a/packages/html-reporter/src/metadataView.tsx b/packages/html-reporter/src/metadataView.tsx
index dcc27acb25..545eb14513 100644
--- a/packages/html-reporter/src/metadataView.tsx
+++ b/packages/html-reporter/src/metadataView.tsx
@@ -23,6 +23,7 @@ import type { Metadata } from '@playwright/test';
import type { CIInfo, GitCommitInfo, MetadataWithCommitInfo } from '@testIsomorphic/types';
import { CopyToClipboardContainer } from './copyToClipboard';
import { linkifyText } from '@web/renderUtils';
+import { SearchParamsContext } from './links';
class ErrorBoundary extends React.Component<React.PropsWithChildren<{}>, { error: Error | null, errorInfo: React.ErrorInfo | null }> {
override state: { error: Error | null, errorInfo: React.ErrorInfo | null } = {
@@ -55,8 +56,9 @@ export const MetadataView: React.FC<{ metadata: Metadata }> = params => {
};
const InnerMetadataView: React.FC<{ metadata: Metadata }> = params => {
+ const searchParams = React.useContext(SearchParamsContext);
const commitInfo = params.metadata as MetadataWithCommitInfo;
- const otherEntries = Object.entries(params.metadata).filter(([key]) => !ignoreKeys.has(key));
+ const otherEntries = searchParams.has('show-metadata-other') ? Object.entries(params.metadata).filter(([key]) => !ignoreKeys.has(key)) : [];
const hasMetadata = commitInfo.ci || commitInfo.gitCommit || otherEntries.length > 0;
if (!hasMetadata)
return;
diff --git a/tests/playwright-test/reporter-html.spec.ts b/tests/playwright-test/reporter-html.spec.ts
index 88faf5695e..178266d514 100644
--- a/tests/playwright-test/reporter-html.spec.ts
+++ b/tests/playwright-test/reporter-html.spec.ts
@@ -1193,7 +1193,6 @@ for (const useIntermediateMergeReport of [true, false] as const) {
'playwright.config.ts': `
export default {
captureGitInfo: { commit: true },
- metadata: { foo: 'value1', bar: { prop: 'value2' }, baz: ['value3', 123] }
};
`,
'example.spec.ts': `
@@ -1216,21 +1215,13 @@ for (const useIntermediateMergeReport of [true, false] as const) {
- list:
- listitem: "chore(html): make this test look nice"
- listitem: /William <shakespeare@example\\.local>/
- - list:
- - listitem: "foo : value1"
- - listitem: "bar : {\\"prop\\":\\"value2\\"}"
- - listitem: "baz : [\\"value3\\",123]"
`);
});
test('should include commit metadata w/ CI', async ({ runInlineTest, writeFiles, showReport, page }) => {
const files = {
'uncommitted.txt': `uncommitted file`,
- 'playwright.config.ts': `
- export default {
- metadata: { foo: 'value1', bar: { prop: 'value2' }, baz: ['value3', 123] }
- };
- `,
+ 'playwright.config.ts': `export default {}`,
'example.spec.ts': `
import { test, expect } from '@playwright/test';
test('sample', async ({}) => { expect(2).toBe(2); });
@@ -1256,21 +1247,13 @@ for (const useIntermediateMergeReport of [true, false] as const) {
- listitem:
- 'link "chore(html): make this test look nice"'
- listitem: /William <shakespeare@example\\.local>/
- - list:
- - listitem: "foo : value1"
- - listitem: "bar : {\\"prop\\":\\"value2\\"}"
- - listitem: "baz : [\\"value3\\",123]"
`);
});
test('should include PR metadata on GHA', async ({ runInlineTest, writeFiles, showReport, page }) => {
const files = {
'uncommitted.txt': `uncommitted file`,
- 'playwright.config.ts': `
- export default {
- metadata: { foo: 'value1', bar: { prop: 'value2' }, baz: ['value3', 123] }
- };
- `,
+ 'playwright.config.ts': `export default {}`,
'example.spec.ts': `
import { test, expect } from '@playwright/test';
test('sample', async ({}) => { expect(2).toBe(2); });
@@ -1307,10 +1290,6 @@ for (const useIntermediateMergeReport of [true, false] as const) {
- listitem:
- link "My PR"
- listitem: /William <[email protected]>/
- - list:
- - listitem: "foo : value1"
- - listitem: "bar : {\\"prop\\":\\"value2\\"}"
- - listitem: "baz : [\\"value3\\",123]"
`);
});
@@ -2770,15 +2749,7 @@ for (const useIntermediateMergeReport of [true, false] as const) {
test('should show AI prompt', async ({ runInlineTest, writeFiles, showReport, page }) => {
const files = {
'uncommitted.txt': `uncommitted file`,
- 'playwright.config.ts': `
- export default {
- metadata: {
- foo: 'value1',
- bar: { prop: 'value2' },
- baz: ['value3', 123]
- }
- };
- `,
+ 'playwright.config.ts': `export default {}`,
'example.spec.ts': `
import { test, expect } from '@playwright/test';
test('sample', async ({ page }) => {