Skip to content

Commit d69d3b2

Browse files
committed
Add diff pixel ratio for screenshot comparison
1 parent 02e78b9 commit d69d3b2

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

tests/utils/screenshots.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@ export async function hideCursor(node: Locator, callback: () => Promise<void>) {
99
await cursor.evaluate((element) => (element.style.display = null));
1010
}
1111

12+
const MAX_DIFF_PIXEL_RATIO = 0.01;
13+
1214
export function checkScreenshot(node: Locator, message: string) {
13-
return hideCursor(node, () => expect(node, message).toHaveScreenshot());
15+
return hideCursor(node, () =>
16+
expect(node, message).toHaveScreenshot({
17+
maxDiffPixelRatio: MAX_DIFF_PIXEL_RATIO,
18+
}),
19+
);
1420
}
1521

1622
export function checkEditorView(editor: Locator, message: string) {
@@ -34,6 +40,9 @@ export function checkEditorView(editor: Locator, message: string) {
3440
height: boundingBox.height + margins.bottom,
3541
};
3642

37-
await expect(editor.page(), message).toHaveScreenshot({ clip });
43+
await expect(editor.page(), message).toHaveScreenshot({
44+
clip,
45+
maxDiffPixelRatio: MAX_DIFF_PIXEL_RATIO,
46+
});
3847
});
3948
}

0 commit comments

Comments
 (0)