Skip to content

v1.0.2-beta.0

Pre-release
Pre-release

Choose a tag to compare

@bhokaremoin bhokaremoin released this 13 Mar 11:01
· 11 commits to main since this release
ee47bca

✨ New Features

Responsive Snapshot Capture

  • Added responsiveSnapshotCapture option to capture DOM across multiple viewport widths in a single snapshot() call
  • Viewport widths and heights are fetched dynamically from the Percy CLI GET /percy/widths-config endpoint
  • For each configured width: resizes the viewport → waits for resize (via PercyDOM.waitForResize()) → optionally reloads → optionally sleeps → captures DOM
  • Original viewport is preserved and restored after all widths are captured
  • Each snapshot is tagged with its capture width for accurate comparison
  • Automatically disabled when percy.deferUploads: true

Cookie Capture

  • Before each DOM serialization, all page cookies are collected via page.context().cookies() (with graceful fallback on failure)
  • Cookies (name, value, domain, path, expires, httpOnly, secure, sameSite) are attached as cookies in the snapshot payload, enabling the CLI to use them during asset discovery

Cross-Origin (CORS) Iframe Capture

  • Detects cross-origin iframes by comparing each frame's host against the main page host
  • For each cross-origin frame: injects the Percy DOM script → serializes the frame DOM independently → matches it to the main page via data-percy-element-id
  • Serialized CORS iframe data is stored in domSnapshot.corsIframes for CLI-side stitching

🔧 Enhancements

Structured Logging

  • log() now POSTs {message, level} JSON to the Percy CLI /percy/log endpoint in addition to printing to stdout
  • Debug-level messages are suppressed from stdout unless PERCY_LOGLEVEL=debug is set

HTTP Timeout (Percy CLI Sync Feature)

  • request() now applies a 600-second socket/connect timeout to support Percy CLI's synchronous processing mode, preventing long snapshot POST operations from hanging indefinitely while the CLI processes and uploads snapshots synchronously

CLI Config Caching

  • The healthcheck response now stores the CLI's config object
  • Drives responsiveSnapshotCapture and deferUploads behavior without requiring a CLI restart

⚙️ Configuration Options

New environment variables:

Variable Description
RESPONSIVE_CAPTURE_SLEEP_TIME Delay in seconds between each viewport-width capture
PERCY_RESPONSIVE_CAPTURE_RELOAD_PAGE Reload page between captures (true/false)
PERCY_RESPONSIVE_CAPTURE_MIN_HEIGHT Adjust capture height to account for browser chrome (outerHeight - innerHeight + minH)

Enable responsive capture via SDK option:

options.put("responsiveSnapshotCapture", true);

Or via CLI config:

snapshot:
  responsiveSnapshotCapture: true

📋 Requirements

⚠️ Percy CLI v1.31.10-beta.0 or higher is required — this version is a hard dependency for both Responsive Snapshot Capture (uses the new GET /percy/widths-config endpoint) and CORS Iframe Capture (requires CLI-side handling of the domSnapshot.corsIframes field). Neither feature will function correctly on earlier CLI versions.

  • CLI must expose GET /percy/widths-config for responsive capture width resolution
  • CLI must process domSnapshot.corsIframes for cross-origin iframe DOM stitching

💥 Impact

  • Breaking: Projects using CORS iframes must update Percy CLI to v1.31.10-beta.0 or higher
  • Compatibility: Responsive capture is automatically disabled when deferUploads is enabled
  • Performance: 600-second HTTP timeout prevents silent hangs on large snapshot payloads during CLI sync mode

What's Changed

  • feat: add responsive snapshot capture, cookie capture, and cross-origin iframe support by @bhokaremoin in #25

New Contributors

Full Changelog: v1.0.1...v1.0.2-beta.0