Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ability to specify ignoreDiffPixelCount in assertView #849

Merged
merged 1 commit into from
Feb 29, 2024

Conversation

KuznetsovRoman
Copy link
Member

@KuznetsovRoman KuznetsovRoman commented Feb 21, 2024

What is done

Implemented ignoreDiffPixelCount optional param to assertView command.
With there params, it would be possible to ignore 2-5 pixel image diffs, which are hard to get rid of

Example:

it('example', async ({browser}) => {
    // ignores up to 5 diff pixels
    await browser.assertView('some-state', 'some-selector', {ignoreDiffPixelCount: 5});

    // ignores up to 5% diff pixels
    await browser.assertView('other-state', 'other-selector', {ignoreDiffPixelCount: "5%"});
});

@KuznetsovRoman KuznetsovRoman changed the title feat: add ability to specify maxDiffPixels and maxDiffPixelRatio in a… feat: add ability to specify maxDiffPixels and in assertView Feb 21, 2024
@KuznetsovRoman KuznetsovRoman force-pushed the HERMIONE-1403.max_pixels_diff branch 5 times, most recently from b690cfd to d747364 Compare February 22, 2024 08:20
@@ -25,5 +34,16 @@ exports.handleImageDiff = (currImg, refImg, state, opts) => {
...buildDiffOpts,
};

return Promise.reject(ImageDiffError.create(state, currImg, refImg, diffOpts, diffAreas, diffBuffer));
return Promise.reject(
ImageDiffError.create({
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed this method's params to be a single object. This would be passed into html-reporter

src/browser/commands/assert-view/index.js Outdated Show resolved Hide resolved
*
* @defaultValue `0`
*/
maxDiffPixels?: `${number}%` | number;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out, you can do such things in typescript.
Using `${number}%` | number directly, without extra type, because this way you can get clear understanding about what type this field wants value to be:
image

@KuznetsovRoman KuznetsovRoman changed the title feat: add ability to specify maxDiffPixels and in assertView feat: add ability to specify maxDiffPixels in assertView Feb 22, 2024
Copy link
Member

@sipayRT sipayRT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в остальном ок

README.md Outdated Show resolved Hide resolved
src/browser/commands/assert-view/index.js Outdated Show resolved Hide resolved
src/browser/commands/assert-view/index.js Outdated Show resolved Hide resolved
src/browser/commands/assert-view/index.js Outdated Show resolved Hide resolved
src/browser/commands/assert-view/index.js Outdated Show resolved Hide resolved
src/browser/commands/types.ts Outdated Show resolved Hide resolved
* @example '1.5%'
*
* @remarks
* Usefull, when you have 2-5 different pixels you can't get rid of using `tolerance` and `antialiasingTolerance`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

меня здесь смущает связка "get rid of using tolerance". Выше писал как можно перефразировать

@KuznetsovRoman KuznetsovRoman changed the title feat: add ability to specify maxDiffPixels in assertView feat: add ability to specify ignoreDiffPixelCount in assertView Feb 27, 2024
@KuznetsovRoman KuznetsovRoman force-pushed the HERMIONE-1403.max_pixels_diff branch 2 times, most recently from 7cf5930 to 7a7230d Compare February 27, 2024 08:35
@KuznetsovRoman KuznetsovRoman merged commit 77ef6e1 into master Feb 29, 2024
2 checks passed
@KuznetsovRoman KuznetsovRoman deleted the HERMIONE-1403.max_pixels_diff branch February 29, 2024 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants