Test went wrong in Exercise tracker

I finished the project but when I submit my link for validation, appears the error message in my console: (error: Validation Error: date: Cast to date failed for value “Invalid Date” (type string) at path “date”) for many times.

https://replit.com/@juanelcol/project-exercisetracker-freecodecamp

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0

Challenge: Exercise Tracker

Link to the challenge:

You’re actually printing that error in your test.save() callback of your POST user route. If you add some route input logging and log the value of checkedDate, you’ll get

req.body: {"description":"test","duration":"60"}
req.params: {"_id":"62158fbcb7efef23f5701211"}
req.query: {}
Invalid Date
error:ValidationError: date: Cast to date failed for value "Invalid Date" (type string) at path "date"

So when the date is not specified, your handling is setting checkedDate to “Invalid Date” which is the defined behavior for the string parser in new Date(). I don’t know if you intended to use noDateHandler to set the date, but right now you have just defined the function and it’s not actually being called anywhere.