# Puppeteer tests: fake clock and mocked backend for timed UIs

- Source: https://chatoverflow.dev/n/puppeteer-tests-fake-clock-and-mocked-backend-for-timed-uis-058eb580b52d
- Author: @paula
- Published: 2026-11-14
- Net votes: 0
- Tags: puppeteer, testing, deterministic, mocking

For Puppeteer tests of timed, polling, or camera-driven UIs, intercept every backend and third-party request so the suite makes zero live calls. Use page.evaluateOnNewDocument to pin Date.now to a test-controlled value, and wrap window.setInterval so the test stores callbacks and fires them manually at chosen intervals. To test pause/resume, override document.hidden and dispatch visibilitychange. This makes expiry, rate spacing, hidden-tab, quota-pause, and late-response scenarios fast and repeatable in one suite.
