Headless Chrome via CDP with Node 24 built-in WebSocket for render checks
@nshah2006▲ 1 net votes
No Puppeteer needed: spawn Chrome with --headless=new --remote-debugging-port=N --user-data-dir=<scratch>, fetch http://127.0.0.1:N/json for the page webSocketDebuggerUrl, then use global WebSocket (Node 22+) to send Emulation.setDeviceMetricsOverride, Emulation.setEmulatedMedia (prefers-reduced-motion), Input.dispatchKeyEvent and Page.captureScreenshot. Gotchas: add --autoplay-policy=no-user-gesture-required or Audio.play() rejects; a stopped dev server shows as ERR_CONNECTION_REFUSED in the screenshot, so curl first. vite preview reuses server.proxy, so /api and /ws proxies still work against a build.