Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To make a page see a fixed JavaScript date, install a Date override with page.evaluateOnNewDocument() before navigating. If your test also needs timers and browser scheduling to use synthetic time, use Chrome DevTools Protocol (CDP) virtual time instead. Set the timezone separately when local-time methods or formatting matter: timezone emulation changes how an instant is interpreted, not the instant itself.

Choose the right kind of date override

Need Use What it controls
Make page code that reads JavaScript Date see a fixed instant page.evaluateOnNewDocument() with a Date patch The page JavaScript environment where the override is installed. It does not establish that every browser subsystem, worker, or native API uses a frozen wall clock.
Run timers and scheduler work against synthetic time CDP Emulation.setVirtualTimePolicy A synthetic time source for browser frames. The protocol currently marks this command experimental, so check it against the Chromium version used in your test.
Test local clock methods or date formatting in a particular region page.emulateTimezone() Timezone interpretation and rendering; it does not set the clock’s instant.

Puppeteer describes page.evaluate() as evaluating a function in the existing page context and returning its result. That is too late if startup scripts have already read or cached date values. The pre-navigation hook is the appropriate page-level option when the site must encounter the override before its scripts execute. See the Puppeteer Page.evaluate() API and Page.evaluateOnNewDocument() API.

Fix JavaScript Date before the page loads

Register the override before goto(). The sample fixes no-argument new Date() and Date.now(), while preserving the original constructor’s behavior for calls that pass arguments.

const fixedTime = new Date('2030-01-02T03:04:05.000Z').valueOf();

await page.evaluateOnNewDocument((timestamp) => {
  const OriginalDate = Date;

  class FixedDate extends OriginalDate {
    constructor(...args) {
      if (args.length === 0) {
        super(timestamp);
      } else {
        super(...args);
      }
    }

    static now() {
      return timestamp;
    }
  }

  Object.setPrototypeOf(FixedDate, OriginalDate);
  globalThis.Date = FixedDate;
}, fixedTime);

await page.goto('https://example.test');

The argument passed to evaluateOnNewDocument() supplies the timestamp to the page-side function. The hook runs before page scripts and also applies when child frames are attached or navigated, according to Puppeteer’s API documentation. The patch is still a JavaScript-level technique: check separately if your test relies on workers, isolated realms, or code that cached Date in another environment.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Logitech M185 Compact Ambidextrous 2.4 GHz Wireless Mouse - Swift Grey
  • Compact Mouse: With a comfortable and contoured shape, this Logitech ambidextrous wireless mouse feels great in either right or left hand and is far superior to a touchpad
  • Durable and Reliable: This USB wireless mouse features a line-by-line scroll wheel, up to 1 year of battery life (2) thanks to a smart sleep mode function, and comes with the included AA battery
  • Universal Compatibility: Your Logitech mouse works with your Windows PC, Mac, or laptop, so no matter what type of computer you own today or buy tomorrow your mouse will be compatible
  • Plug and Play Simplicity: Just plug in the tiny nano USB receiver and start working in seconds with a strong, reliable connection to your wireless computer mouse up to 33 feet / 10 m (5)
  • Better than touchpad: Get more done by adding M185 to your laptop; according to a recent study, laptop users who chose this mouse over a touchpad were 50% more productive (3) and worked 30% faster (4)

Use CDP virtual time for timers and scheduler behavior

When a test needs browser scheduling and timers to progress against a synthetic clock, create a CDP session and set virtual time. The protocol says this command turns on virtual time for all frames, replacing real time with a synthetic source. Its initialVirtualTime parameter is expressed in seconds since the epoch; JavaScript’s Date.parse() returns milliseconds, so divide by 1,000.

const client = await page.createCDPSession();

await client.send('Emulation.setVirtualTimePolicy', {
  policy: 'pauseIfNetworkFetchesPending',
  initialVirtualTime: Date.parse('2030-01-02T03:04:05.000Z') / 1000,
  budget: 5000,
});

await page.goto('https://example.test');

The policy may be advance, pause, or pauseIfNetworkFetchesPending. With a budget, virtual time pauses after the specified virtual milliseconds and emits virtualTimeBudgetExpired. This code is a starting pattern, not a browser-independent guarantee: confirm policy timing and behavior for the Puppeteer and Chromium versions in your CI. Some tests need the policy before navigation; others need a bounded period of virtual advancement after the page loads. The CDP reference labels Emulation.setVirtualTimePolicy experimental. See the Chrome DevTools Protocol Emulation domain and Puppeteer’s Page.createCDPSession() API. Close or detach the session when the test is finished, following the lifecycle supported by your installed Puppeteer version.

Rank #2
Sale
Logitech G305 Lightspeed Wireless Gaming Mouse - Black
  • The next-generation optical HERO sensor delivers incredible performance and up to 10x the power efficiency over previous generations, with 400 IPS precision and up to 12,000 DPI sensitivity
  • Ultra-fast LIGHTSPEED wireless technology gives you a lag-free gaming experience, delivering incredible responsiveness and reliability with 1 ms report rate for competition-level performance
  • G305 wireless mouse boasts an incredible 250 hours of continuous gameplay on just 1 AA battery; switch to Endurance mode via Logitech G HUB software and extend battery life up to 9 months
  • Wireless does not have to mean heavy, G305 lightweight mouse provides high maneuverability coming in at only 3.4 oz thanks to efficient lightweight mechanical design and ultra-efficient battery usage
  • The durable, compact design with built-in nano receiver storage makes G305 not just a great portable desktop mouse, but also a great laptop travel companion, use with a gaming laptop and play anywhere

Set timezone independently

If assertions use local-time methods or formatted output, set the timezone as well as the clock behavior:

await page.emulateTimezone('America/Los_Angeles');

Puppeteer documents emulateTimezone(timezoneId) for changing the page timezone; passing null disables emulation. Apply it before navigation if startup code depends on the zone. A fixed instant can render as different local calendar dates near midnight in different timezones; that reflects timezone interpretation, not a changed instant. See the Puppeteer Page.emulateTimezone() API.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Logitech M185 Compact Ambidextrous Wireless Mouse with Rubber Grips - Blue
  • Compact Mouse: With a comfortable and contoured shape, this Logitech ambidextrous wireless mouse feels great in either right or left hand and is far superior to a touchpad
  • Durable and Reliable: This USB wireless mouse features a line-by-line scroll wheel, up to 1 year of battery life (2) thanks to a smart sleep mode function, and comes with the included AA battery
  • Universal Compatibility: Your Logitech mouse works with your Windows PC, Mac, or laptop, so no matter what type of computer you own today or buy tomorrow your mouse will be compatible
  • Plug and Play Simplicity: Just plug in the tiny nano USB receiver and start working in seconds with a strong, reliable connection to your wireless computer mouse up to 33 feet / 10 m (5)
  • Better than touchpad: Get more done by adding M185 to your laptop; according to a recent study, laptop users who chose this mouse over a touchpad were 50% more productive (3) and worked 30% faster (4)

Common failures and how to fix them

  • The page still shows the real date. If the override ran through page.evaluate() after navigation, startup code may already have read or cached the value. Register the patch with evaluateOnNewDocument() before goto().
  • The date is fixed, but timers do not behave as expected. Patching JavaScript Date does not configure the browser scheduler. Use CDP virtual time and verify its policy and timing against your Chromium build.
  • The displayed calendar day is unexpected. Check the selected timezone and whether the asserted value is UTC or local time. Timezone emulation and the chosen instant are separate settings.
  • A frame sees a different value. Puppeteer’s pre-script hook is documented to run for child frames when attached or navigated, while CDP virtual time applies to all frames. Check whether the code instead runs in a worker, isolated realm, or context that cached the original constructor.
  • CDP rejects the command or behavior differs in CI. The virtual-time command is experimental. Check the protocol supported by the exact Chrome/Chromium build and the Puppeteer version installed by the project.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your goal is to capture a page rather than run a Puppeteer date test, ScreenshotNeo takes a website screenshot through one API request. Its clean-shot steps accept cookie or consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers identify the page verdict and billing status. It also offers an MCP server with take_screenshot, get_page_info, and capture_pdf for AI agents.

With Node.js and node-fetch available as the global fetch in a current runtime, this makes the request and returns the response; save the response body if you need a local image file:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://example.test' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

See the ScreenshotNeo API documentation for request options and response handling. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for free.

Quick Recap

SaleBestseller No. 1
Logitech M185 Compact Ambidextrous 2.4 GHz Wireless Mouse - Swift Grey
Logitech M185 Compact Ambidextrous 2.4 GHz Wireless Mouse - Swift Grey
Product carbon footprint: 3.97 kg CO2e; Contoured shape: Gives you more comfort and control
$12.34
SaleBestseller No. 3
SaleBestseller No. 4
Amazon Basics 3-Button USB Wired Mouse with Responsive Tracking, Plug & Play, Compatible with Windows and Mac, Black
Amazon Basics 3-Button USB Wired Mouse with Responsive Tracking, Plug & Play, Compatible with Windows and Mac, Black
Computer mouse for easily navigating a computer interface; click, scroll, and more; 3 buttons offer effortless fingertip control
$6.79
Best Value
Sale
Acer Wireless Mouse for Laptop, 2.4GHz Computer Mouse 3 Adjustable 1600 DPI
  • 【Plug and Play for Home/Office/School】The wireless computer mouse features 2.4GHz connectivity, delivering a stable, interference-free connection up to 32ft. Designed for 𝐦𝐞𝐝𝐢𝐮𝐦 𝐭𝐨 𝐥𝐚𝐫𝐠𝐞 𝐬𝐢𝐳𝐞𝐝 𝐡𝐚𝐧𝐝𝐬, it ensures comfortable use all day. Simply plug in the USB-A receiver for instant pairing—no drivers needed. 📌📌 If the mouse isn’t suitable, place the USB receiver in the battery compartment and return both.
  • 【3 Levels Adjustable DPI】This travel USB mouse offers 3 adjustable DPI settings (800, 1200, 1600), allowing you to customize sensitivity for precise design work. Effortlessly switch to match your task and elevate your productivity. 📌 Please remove the film at the bottom of the mouse before use.
  • 【Effortless Browsing】Equipped with forward and backward buttons, this computer mice streamlines your workflow, making it easy to navigate through web pages and files with a simple click. 📌Side button does not work on Mac.
  • 【Visible Indicator Light】 The pc mouse features a visual indicator for DPI levels and low battery alerts. The red light flashes once for 800 DPI, twice for 1200 DPI, and three times for 1600 DPI. When the battery level is below 10%, the light flashes red until the mouse is completely out of power.
  • 【Click to Wake】With smart sleep mode, it saves power by standby after 10 inactive minutes, just 2-3 clicks to wake. This efficient design delivers 3x longer battery life than motion-wake mice. Engineered for durability, its buttons and scroll wheel are tested for 10 million clicks, ensuring long-term reliability and consistent performance.
Rank #4
Sale
Amazon Basics 3-Button USB Wired Mouse with Responsive Tracking, Plug & Play, Compatible with Windows and Mac, Black
  • Computer mouse for easily navigating a computer interface; click, scroll, and more
  • USB-A wired connection; if existing device only supports USB-C, an additional adapter will be required
  • High-definition (1000 dpi) optical tracking ensures responsive cursor control for precise tracking and easy text selection
  • 3 buttons offer effortless fingertip control
  • Plug-and-go ready for instant use

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.