Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/src/test-reporters-js.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ HTML report supports the following configuration options and environment variabl
| `PLAYWRIGHT_HTML_NO_COPY_PROMPT` | `noCopyPrompt` | If true, disable rendering of the Copy prompt for errors. Supports `true`, `1`, `false`, and `0`. | `false`
| `PLAYWRIGHT_HTML_NO_SNIPPETS` | `noSnippets` | If true, disable rendering code snippets in the action log. If there is a top level error, that report section with code snippet will still render. Supports `true`, `1`, `false`, and `0`. | `false`
| `PLAYWRIGHT_HTML_DO_NOT_INLINE_ASSETS` | `doNotInlineAssets` | If true, JavaScript, CSS and report data are written as separate files alongside `index.html` instead of being embedded inline. Use this when serving the report under a strict [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CSP) that disallows inline scripts and styles. Supports `true`, `1`, `false`, and `0`. | `false`
| `PLAYWRIGHT_HTML_MERGE_FILES` | `mergeFiles` | If true, tests are grouped by their top-level `test.describe()` title instead of the file they belong to. Supports `true`, `1`, `false`, and `0`. | `false`

### Blob reporter

Expand Down
7 changes: 0 additions & 7 deletions packages/html-reporter/src/headerView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { filterWithQuery } from './filter';
import { linkifyText } from '@web/renderUtils';
import { Dialog } from '@web/shared/dialog';
import { kThemeOptions, type Theme, useThemeSetting } from '@web/theme';
import { useSetting } from '@web/uiUtils';

export const HeaderView: React.FC<{
title: string | undefined,
Expand Down Expand Up @@ -132,7 +131,6 @@ const SettingsButton: React.FC = () => {
const settingsRef = React.useRef<HTMLDivElement>(null);
const [settingsOpen, setSettingsOpen] = React.useState(false);
const [theme, setTheme] = useThemeSetting();
const [mergeFiles, setMergeFiles] = useSetting('mergeFiles', false);

return <>
<div
Expand Down Expand Up @@ -165,11 +163,6 @@ const SettingsButton: React.FC = () => {
))}
</select>
</label>

<label style={{ cursor: 'pointer', display: 'flex', alignItems: 'center', gap: 4 }}>
<input type='checkbox' checked={mergeFiles} onChange={() => setMergeFiles(!mergeFiles)}></input>
Merge files
</label>
</Dialog>
</>;
};
Expand Down
3 changes: 1 addition & 2 deletions packages/html-reporter/src/reportView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import './reportView.css';
import { TestCaseView } from './testCaseView';
import { TestFilesHeader, TestFilesView } from './testFilesView';
import './theme.css';
import { useSetting } from '@web/uiUtils';
import { Speedboard } from './speedboard';

declare global {
Expand Down Expand Up @@ -54,7 +53,7 @@ export const ReportView: React.FC<{
const [metadataVisible, setMetadataVisible] = React.useState(false);
const [errorsVisible, setErrorsVisible] = React.useState(true);
const speedboard = searchParams.has('speedboard');
const [mergeFiles] = useSetting('mergeFiles', false);
const mergeFiles = !!report?.json()?.options.mergeFiles;
const testId = searchParams.get('testId');
const q = searchParams.get('q')?.toString() || '';
const filterParam = q ? '&q=' + q : '';
Expand Down
1 change: 1 addition & 0 deletions packages/html-reporter/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export type HTMLReportOptions = {
title?: string;
noCopyPrompt?: boolean;
noSnippets?: boolean;
mergeFiles?: boolean;
};

export type HTMLReport = {
Expand Down
2 changes: 2 additions & 0 deletions packages/playwright/src/reporters/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,13 @@ class HtmlReporter implements ReporterV2 {
const noSnippets = parseBooleanEnvVar('PLAYWRIGHT_HTML_NO_SNIPPETS') ?? this._options.noSnippets;
const noCopyPrompt = parseBooleanEnvVar('PLAYWRIGHT_HTML_NO_COPY_PROMPT') ?? this._options.noCopyPrompt;
const doNotInlineAssets = parseBooleanEnvVar('PLAYWRIGHT_HTML_DO_NOT_INLINE_ASSETS') ?? this._options.doNotInlineAssets ?? false;
const mergeFiles = parseBooleanEnvVar('PLAYWRIGHT_HTML_MERGE_FILES') ?? this._options.mergeFiles;

const builder = new HtmlBuilder(yazl, this.config, this._outputFolder, this._attachmentsBaseURL, doNotInlineAssets, {
title: process.env.PLAYWRIGHT_HTML_TITLE || this._options.title,
noSnippets,
noCopyPrompt,
mergeFiles,
});
this._buildResult = await builder.build(this.config.metadata, projectSuites, result, this._topLevelErrors, this._machines);
}
Expand Down
1 change: 1 addition & 0 deletions packages/playwright/types/test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export type HtmlReporterOptions = {
noSnippets?: boolean;
noCopyPrompt?: boolean;
doNotInlineAssets?: boolean;
mergeFiles?: boolean;
};

export type ReporterDescription = Readonly<
Expand Down
8 changes: 4 additions & 4 deletions tests/playwright-test/reporter-html.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3508,6 +3508,9 @@ for (const useIntermediateMergeReport of [true, false] as const) {

test('should support merge files option', async ({ runInlineTest, showReport, page }) => {
await runInlineTest({
'playwright.config.ts': `
export default { reporter: [['html', { mergeFiles: true }], ['line']] };
`,
'a.test.js': `
import { test, expect } from '@playwright/test';
test.describe('describe', () => {
Expand All @@ -3521,13 +3524,10 @@ test('should support merge files option', async ({ runInlineTest, showReport, pa
test('test 3', async ({}) => {});
});
`,
}, { reporter: 'dot,html' }, { PLAYWRIGHT_HTML_OPEN: 'never' });
}, {}, { PLAYWRIGHT_HTML_OPEN: 'never' });

await showReport();

await page.getByRole('button', { name: 'Settings' }).click();
await page.getByRole('checkbox', { name: 'Merge files' }).click();

await expect(page).toMatchAriaSnapshot(`
- button "<anonymous>" [expanded]
- region:
Expand Down
1 change: 1 addition & 0 deletions utils/generate_types/overrides-test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type HtmlReporterOptions = {
noSnippets?: boolean;
noCopyPrompt?: boolean;
doNotInlineAssets?: boolean;
mergeFiles?: boolean;
};

export type ReporterDescription = Readonly<
Expand Down
Loading