diff --git a/packages/html-reporter/src/imageDiffView.tsx b/packages/html-reporter/src/imageDiffView.tsx
new file mode 100644
index 0000000000..6b4b786d7f
--- /dev/null
+++ b/packages/html-reporter/src/imageDiffView.tsx
@@ -0,0 +1,65 @@
+/*
+ Copyright (c) Microsoft Corporation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+import type { TestAttachment } from '@playwright-test/reporters/html';
+import * as React from 'react';
+import { AttachmentLink } from './links';
+import { TabbedPane } from './tabbedPane';
+import './testResultView.css';
+
+export type ImageDiff = {
+ name: string,
+ left?: { attachment: TestAttachment, title: string },
+ right?: { attachment: TestAttachment, title: string },
+ diff?: { attachment: TestAttachment, title: string },
+};
+
+export const ImageDiffView: React.FunctionComponent<{
+ imageDiff: ImageDiff,
+}> = ({ imageDiff: diff }) => {
+ // Pre-select a tab called "actual", if any.
+ const [selectedTab, setSelectedTab] = React.useState('left');
+ const diffElement = React.useRef(null);
+ const setMinHeight = () => {
+ if (diffElement.current)
+ diffElement.current.style.minHeight = diffElement.current.offsetHeight + 'px';
+ };
+ const tabs = [
+ {
+ id: 'left',
+ title: diff.left!.title,
+ render: () =>
+ },
+ {
+ id: 'right',
+ title: diff.right!.title,
+ render: () =>
+ },
+ ];
+ if (diff.diff) {
+ tabs.push({
+ id: 'diff',
+ title: diff.diff.title,
+ render: () =>
+ });
+ }
+ return
+
+
+
+ {diff.diff &&
}
+
;
+};
diff --git a/packages/html-reporter/src/testResultView.tsx b/packages/html-reporter/src/testResultView.tsx
index ba38b94d97..88fed67144 100644
--- a/packages/html-reporter/src/testResultView.tsx
+++ b/packages/html-reporter/src/testResultView.tsx
@@ -18,21 +18,14 @@ import type { TestAttachment, TestCase, TestResult, TestStep } from '@playwright
import ansi2html from 'ansi-to-html';
import * as React from 'react';
import { TreeItem } from './treeItem';
-import { TabbedPane } from './tabbedPane';
import { msToString } from './uiUtils';
import { AutoChip } from './chip';
import { traceImage } from './images';
import { AttachmentLink } from './links';
import { statusIcon } from './statusIcon';
+import { ImageDiff, ImageDiffView } from './imageDiffView';
import './testResultView.css';
-type ImageDiff = {
- name: string,
- left?: { attachment: TestAttachment, title: string },
- right?: { attachment: TestAttachment, title: string },
- diff?: { attachment: TestAttachment, title: string },
-};
-
function groupImageDiffs(screenshots: Set): ImageDiff[] {
const snapshotNameToImageDiff = new Map();
for (const attachment of screenshots) {
@@ -148,43 +141,6 @@ const StepTreeItem: React.FC<{
} : undefined} depth={depth}>;
};
-const ImageDiffView: React.FunctionComponent<{
- imageDiff: ImageDiff,
-}> = ({ imageDiff: diff }) => {
- // Pre-select a tab called "actual", if any.
- const [selectedTab, setSelectedTab] = React.useState('left');
- const diffElement = React.useRef(null);
- const setMinHeight = () => {
- if (diffElement.current)
- diffElement.current.style.minHeight = diffElement.current.offsetHeight + 'px';
- };
- const tabs = [
- {
- id: 'left',
- title: diff.left!.title,
- render: () =>
- },
- {
- id: 'right',
- title: diff.right!.title,
- render: () =>
- },
- ];
- if (diff.diff) {
- tabs.push({
- id: 'diff',
- title: diff.diff.title,
- render: () =>
- });
- }
- return
-
-
-
- {diff.diff &&
}
-
;
-};
-
const ErrorMessage: React.FC<{
error: string;
}> = ({ error }) => {