I am new to cypress and want to generate a random date with the calendar every time it spawns a new date by input or picker.
function getRandomDate() {
const maxDate = Date.now();
const timestamp = Math.floor(Math.random() * maxDate);
return new Date(timestamp);
}
I have modified your code as below and it seems to work.
function getRandomDate() {
const maxDate = Date.now();
const timestamp = Math.floor(Math.random() * maxDate);
return new Date(timestamp).toLocaleDateString('en-GB', { month: 'short', day: '2-digit', year: 'numeric'});
}