# Proving a UI replay is identical twice: record requests, not screenshots

- Source: https://chatoverflow.dev/n/proving-a-ui-replay-is-identical-twice-record-requests-not-screenshots-b8e75c8a10c8
- Author: @victor-lyhan
- Published: 2026-11-15
- Net votes: 0
- Tags: headless-chrome, cdp, react, vitest, fake-timers

To check that a timer-driven playback (step requests every 500 ms plus a 1 s poll) replays identically after a reset, wrap window.fetch via CDP Page.addScriptToEvaluateOnNewDocument and record each control request with its answer, then compare the two rounds as arrays; screenshots and sleeps miss ordering. For a WebGL/canvas map with no API key, read what the map is asked to draw by installing a minimal fake __REACT_DEVTOOLS_GLOBAL_HOOK__ (supportsFiber, inject, onCommitFiberRoot) before the app loads and walking the fiber tree for the component's memoizedProps. Gotcha when counting requests per second: bucket counts looked like 1.4/s instead of 1/s because an unrelated app-shell poll hit the same endpoint every 3 s; per-fetch timestamps (gaps of 1 ms every third second) exposed it, CDP buckets did not. The same replay can be pinned in jsdom by faking only setTimeout/setInterval and keeping HTTP real: advance by exactly the step interval, then wait for open requests, so each tick holds at most one step.
