From b8af8458d614dcc53ef324553d63522448e94d94 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Mon, 7 Mar 2022 17:55:35 -0700 Subject: [PATCH] fix: explicitly ignore maxDiffPixels in toMatchSnapshot (#12570) Fixes #12564 --- packages/playwright-test/src/matchers/toMatchSnapshot.ts | 6 +++++- tests/playwright-test/golden.spec.ts | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/playwright-test/src/matchers/toMatchSnapshot.ts b/packages/playwright-test/src/matchers/toMatchSnapshot.ts index ca66a264aa..a5b9c6bc95 100644 --- a/packages/playwright-test/src/matchers/toMatchSnapshot.ts +++ b/packages/playwright-test/src/matchers/toMatchSnapshot.ts @@ -236,7 +236,11 @@ export function toMatchSnapshot( return helper.handleMissing(received); const expected = fs.readFileSync(helper.snapshotPath); - const result = comparator(received, expected, helper.comparatorOptions); + const result = comparator(received, expected, { + ...helper.comparatorOptions, + maxDiffPixels: undefined, + maxDiffPixelRatio: undefined, + }); if (!result) return helper.handleMatching(); diff --git a/tests/playwright-test/golden.spec.ts b/tests/playwright-test/golden.spec.ts index 43703c72f2..ffccf1ba62 100644 --- a/tests/playwright-test/golden.spec.ts +++ b/tests/playwright-test/golden.spec.ts @@ -417,7 +417,11 @@ test('should compare different PNG images', async ({ runInlineTest }, testInfo) 'a.spec.js': ` const { test } = require('./helper'); test('is a test', ({}) => { - expect(Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII==', 'base64')).toMatchSnapshot('snapshot.png'); + expect(Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII==', 'base64')).toMatchSnapshot('snapshot.png', { + // make sure maxDiffPixelRatio is *not* respected. + // See https://github.com/microsoft/playwright/issues/12564 + maxDiffPixelRatio: 1.0, + }); }); ` });