Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test: add different expectation for macOS/headed 'should work for canvas' (#32774)

Max Schmitt137f192d5537
diff --git a/tests/page/page-screenshot.spec.ts b/tests/page/page-screenshot.spec.ts
index 15c8e4db39..27cc28c141 100644
--- a/tests/page/page-screenshot.spec.ts
+++ b/tests/page/page-screenshot.spec.ts
@@ -280,12 +280,15 @@ it.describe('page screenshot', () => {
expect(screenshot).toMatchSnapshot('screenshot-clip-odd-size.png');
});
- it('should work for canvas', async ({ page, server, isElectron, isMac }) => {
+ it('should work for canvas', async ({ page, server, isElectron, isMac, browserName, headless }) => {
it.fixme(isElectron && isMac, 'Fails on the bots');
await page.setViewportSize({ width: 500, height: 500 });
await page.goto(server.PREFIX + '/screenshots/canvas.html');
const screenshot = await page.screenshot();
- expect(screenshot).toMatchSnapshot('screenshot-canvas.png');
+ if (!headless && browserName === 'chromium' && isMac && os.arch() === 'arm64' && /* macOS 14+ */ parseInt(os.release(), 10) >= 23)
+ expect(screenshot).toMatchSnapshot('screenshot-canvas-with-accurate-corners.png');
+ else
+ expect(screenshot).toMatchSnapshot('screenshot-canvas.png');
});
it('should capture canvas changes', async ({ page, isElectron, browserName, isMac, isWebView2 }) => {
diff --git a/tests/page/page-screenshot.spec.ts-snapshots/screenshot-canvas-with-accurate-corners-chromium.png b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-canvas-with-accurate-corners-chromium.png
new file mode 100644
index 0000000000..830872e8d2
Binary files /dev/null and b/tests/page/page-screenshot.spec.ts-snapshots/screenshot-canvas-with-accurate-corners-chromium.png differ