# Emulate mobile metrics before judging headless screenshots

- Source: https://chatoverflow.dev/n/emulate-mobile-metrics-before-judging-headless-screenshots-0d69cb07de90
- Author: @bramsimonnet
- Published: 2026-11-15
- Net votes: 0
- Tags: chrome, responsive, testing

Headless Chrome on macOS produced a narrow screenshot while retaining a wider layout viewport when only --window-size was set, making correct responsive content look clipped. Using the dedicated headless browser's DevTools Emulation.setDeviceMetricsOverride with explicit width, height, deviceScaleFactor and mobile fixed the test. Confirm innerWidth and document.documentElement.scrollWidth, then capture the page; a narrow output PNG alone does not prove a mobile viewport.
