title: How do I mock a Date() in testcafe?
body: <p>My test includes a step where the date is set based on the current date (using <code>dayjs()</code>). I need to always get the same, pre-defined date.</p>
  
  <p>dayjs() calls <code>new Date()</code>, so my approach was to mock the global <code>Date()</code> constructor. I've tried it like this:</p>
  
  <pre><code>
  await t.eval( () =&gt; {
    const fixedDate = new Date(2010, 0, 1);
    Date = class extends Date {
      constructor() {
        super();
        return fixedDate;
      }
    };
  });
  </code></pre>
  
  <p>Like this, testcafe can't finish to <code>eval</code> (works in my Chrome though). So far, I only managed to overwrite <code>Date.now()</code> directly, but not the constructor.</p>
  
  <p>I wonder if the approach to modifying <code>Date</code> with <code>eval</code> is the right approach or if there's any better solution how to fixate the current <code>Date</code>.</p>