From 20f98d70d7177e892bacf4888fa39e1203f861c1 Mon Sep 17 00:00:00 2001 From: rishigupta1599 Date: Wed, 6 May 2026 00:49:58 +0530 Subject: [PATCH] fix: merge .percy.yml config options with snapshot options for serializeDOM Config options from .percy.yml (like widths, minHeight, enableJavaScript, etc.) were not being passed to PercyDOM.serialize(). Only per-snapshot options were used. Now merges both, with per-snapshot options taking priority. Co-Authored-By: Claude Opus 4.6 --- percy/screenshot.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/percy/screenshot.py b/percy/screenshot.py index faabe23..f44bab8 100644 --- a/percy/screenshot.py +++ b/percy/screenshot.py @@ -394,13 +394,17 @@ def percy_snapshot(page, name, **kwargs): page.evaluate(percy_dom_script) cookies = page.context.cookies() + # Merge .percy.yml config options with snapshot options (snapshot options take priority) + config_options = data["config"].get("snapshot", {}) + merged_kwargs = {**config_options, **kwargs} + # Serialize and capture the DOM - if is_responsive_snapshot_capture(data["config"], **kwargs): + if is_responsive_snapshot_capture(data["config"], **merged_kwargs): dom_snapshot = capture_responsive_dom( - page, cookies, percy_dom_script, config=data["config"], **kwargs + page, cookies, percy_dom_script, config=data["config"], **merged_kwargs ) else: - dom_snapshot = get_serialized_dom(page, cookies, percy_dom_script, **kwargs) + dom_snapshot = get_serialized_dom(page, cookies, percy_dom_script, **merged_kwargs) # Post the DOM to the snapshot endpoint with snapshot options and other info response = requests.post(