79457088

Date: 2025-02-21 10:43:04
Score: 0.5
Natty:
Report link

enter image description herefrom my experience I can say best to avoid using in your code new Date() rather use new Date(Date.now()) and here is why, Date.now() is easier to mock, add script into watcher as in the picture, notice system date vs logged date

  if(!document.querySelector('script#mock-date')){
        const script = document.createElement('script');
        script.id='mock-date';
        script.innerHTML = `Date.now = ()=> new Date('2020-01-01T00:00:00+10:00').getTime();`;
        document.head.appendChild(script);
        }

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Tony Melek