From 02fd8764685a74873c52330d3b7ff312a2bb7a0d Mon Sep 17 00:00:00 2001 From: Ashwithaindla Date: Sun, 15 Nov 2026 23:47:43 +0530 Subject: [PATCH 1/2] feat(html-reporter): add Blink mode for image mismatches Add a 500 ms toggle between actual and expected images in image mismatch views. Fixes: https://github.com/microsoft/playwright/issues/44126 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- packages/html-reporter/src/testErrorView.tsx | 2 +- packages/html-reporter/src/testResultView.tsx | 2 +- packages/web/src/shared/imageDiffView.tsx | 16 ++++++++++++++-- tests/playwright-test/reporter-html.spec.ts | 7 +++++++ 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/packages/html-reporter/src/testErrorView.tsx b/packages/html-reporter/src/testErrorView.tsx index 6fa7bc50ecb17..7b525af78a24f 100644 --- a/packages/html-reporter/src/testErrorView.tsx +++ b/packages/html-reporter/src/testErrorView.tsx @@ -50,7 +50,7 @@ export const TestScreenshotErrorView: React.FC<{ diff: ImageDiff, }> = ({ diff }) => { return
- +
; }; diff --git a/packages/html-reporter/src/testResultView.tsx b/packages/html-reporter/src/testResultView.tsx index 938f84977b2a9..6002708597921 100644 --- a/packages/html-reporter/src/testResultView.tsx +++ b/packages/html-reporter/src/testResultView.tsx @@ -160,7 +160,7 @@ export const TestResultView: React.FC<{ {diffs.map((diff, index) => - + )} diff --git a/packages/web/src/shared/imageDiffView.tsx b/packages/web/src/shared/imageDiffView.tsx index b34393c69c85b..ffd38ffa50dbc 100644 --- a/packages/web/src/shared/imageDiffView.tsx +++ b/packages/web/src/shared/imageDiffView.tsx @@ -63,8 +63,10 @@ export const ImageDiffView: React.FC<{ diff: ImageDiff, noTargetBlank?: boolean, hideDetails?: boolean, -}> = ({ diff, noTargetBlank, hideDetails }) => { - const [mode, setMode] = React.useState<'diff' | 'actual' | 'expected' | 'slider' | 'sxs'>(diff.diff ? 'diff' : 'actual'); + enableBlink?: boolean, +}> = ({ diff, noTargetBlank, hideDetails, enableBlink }) => { + const [mode, setMode] = React.useState<'diff' | 'actual' | 'expected' | 'slider' | 'sxs' | 'blink'>(diff.diff ? 'diff' : 'actual'); + const [blinkExpected, setBlinkExpected] = React.useState(false); const [showSxsDiff, setShowSxsDiff] = React.useState(false); const [expectedImage, setExpectedImage] = React.useState(null); @@ -82,6 +84,13 @@ export const ImageDiffView: React.FC<{ })(); }, [diff]); + React.useEffect(() => { + if (!enableBlink || mode !== 'blink') + return; + const interval = window.setInterval(() => setBlinkExpected(expected => !expected), 500); + return () => window.clearInterval(interval); + }, [enableBlink, mode]); + const isLoaded = expectedImage && actualImage && diffImage; const imageWidth = isLoaded ? Math.max(expectedImage.naturalWidth, actualImage.naturalWidth, 200) : 500; @@ -105,18 +114,21 @@ export const ImageDiffView: React.FC<{ {modeTab('expected', expectedImageTitle)} {modeTab('sxs', 'Side by side')} {modeTab('slider', 'Slider')} + {enableBlink && modeTab('blink', 'Blink')}
{diff.diff && mode === 'diff' && } {diff.diff && mode === 'actual' && } {diff.diff && mode === 'expected' && } {diff.diff && mode === 'slider' && } + {diff.diff && mode === 'blink' && } {diff.diff && mode === 'sxs' &&
setShowSxsDiff(!showSxsDiff)} hideSize={hideDetails} canvasWidth={sxsScale * imageWidth} canvasHeight={sxsScale * imageHeight} scale={sxsScale} />
} {!diff.diff && mode === 'actual' && } {!diff.diff && mode === 'expected' && } + {!diff.diff && mode === 'blink' && } {!diff.diff && mode === 'sxs' &&
diff --git a/tests/playwright-test/reporter-html.spec.ts b/tests/playwright-test/reporter-html.spec.ts index 2bd3d56d4ac97..61e286df5cedb 100644 --- a/tests/playwright-test/reporter-html.spec.ts +++ b/tests/playwright-test/reporter-html.spec.ts @@ -218,6 +218,7 @@ for (const useIntermediateMergeReport of [true, false] as const) { 'Expected', 'Side by side', 'Slider', + 'Blink', ]); for (const testId of ['test-results-image-diff', 'test-screenshot-error-view']) { @@ -252,6 +253,12 @@ for (const useIntermediateMergeReport of [true, false] as const) { await expect(imageDiff.locator('img').first()).toHaveAttribute('alt', 'Expected'); await expect(imageDiff.locator('img').last()).toHaveAttribute('alt', 'Actual'); }); + + await test.step('Blink', async () => { + await imageDiff.getByRole('tab', { name: 'Blink' }).click(); + await expect.poll(() => imageDiff.locator('img').getAttribute('alt')).toBe('Actual'); + await expect.poll(() => imageDiff.locator('img').getAttribute('alt')).toBe('Expected'); + }); }); } }); From 134738ff6e0ed65c9338191dcd9852d5be3de9a2 Mon Sep 17 00:00:00 2001 From: Ashwithaindla Date: Tue, 17 Nov 2026 13:24:19 +0530 Subject: [PATCH 2/2] feat(html-reporter): make Blink a standard image mode Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- packages/html-reporter/src/testErrorView.tsx | 2 +- packages/html-reporter/src/testResultView.tsx | 2 +- packages/web/src/shared/imageDiffView.tsx | 9 ++++----- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/html-reporter/src/testErrorView.tsx b/packages/html-reporter/src/testErrorView.tsx index 7b525af78a24f..6fa7bc50ecb17 100644 --- a/packages/html-reporter/src/testErrorView.tsx +++ b/packages/html-reporter/src/testErrorView.tsx @@ -50,7 +50,7 @@ export const TestScreenshotErrorView: React.FC<{ diff: ImageDiff, }> = ({ diff }) => { return
- +
; }; diff --git a/packages/html-reporter/src/testResultView.tsx b/packages/html-reporter/src/testResultView.tsx index 6002708597921..938f84977b2a9 100644 --- a/packages/html-reporter/src/testResultView.tsx +++ b/packages/html-reporter/src/testResultView.tsx @@ -160,7 +160,7 @@ export const TestResultView: React.FC<{ {diffs.map((diff, index) => - + )} diff --git a/packages/web/src/shared/imageDiffView.tsx b/packages/web/src/shared/imageDiffView.tsx index ffd38ffa50dbc..0247afbb4c237 100644 --- a/packages/web/src/shared/imageDiffView.tsx +++ b/packages/web/src/shared/imageDiffView.tsx @@ -63,8 +63,7 @@ export const ImageDiffView: React.FC<{ diff: ImageDiff, noTargetBlank?: boolean, hideDetails?: boolean, - enableBlink?: boolean, -}> = ({ diff, noTargetBlank, hideDetails, enableBlink }) => { +}> = ({ diff, noTargetBlank, hideDetails }) => { const [mode, setMode] = React.useState<'diff' | 'actual' | 'expected' | 'slider' | 'sxs' | 'blink'>(diff.diff ? 'diff' : 'actual'); const [blinkExpected, setBlinkExpected] = React.useState(false); const [showSxsDiff, setShowSxsDiff] = React.useState(false); @@ -85,11 +84,11 @@ export const ImageDiffView: React.FC<{ }, [diff]); React.useEffect(() => { - if (!enableBlink || mode !== 'blink') + if (mode !== 'blink') return; const interval = window.setInterval(() => setBlinkExpected(expected => !expected), 500); return () => window.clearInterval(interval); - }, [enableBlink, mode]); + }, [mode]); const isLoaded = expectedImage && actualImage && diffImage; @@ -114,7 +113,7 @@ export const ImageDiffView: React.FC<{ {modeTab('expected', expectedImageTitle)} {modeTab('sxs', 'Side by side')} {modeTab('slider', 'Slider')} - {enableBlink && modeTab('blink', 'Blink')} + {modeTab('blink', 'Blink')}
{diff.diff && mode === 'diff' && }