fix: explicitly ignore maxDiffPixels in toMatchSnapshot (#12570)

Fixes #12564
This commit is contained in:
Andrey Lushnikov 2022-03-07 17:55:35 -07:00 committed by GitHub
parent e8ad7eb3f2
commit b8af8458d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View file

@ -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();

View file

@ -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,
});
});
`
});