Exercise Tracker - Test fails for no apparent reason

Tell us what’s happening:
My application appears to work perfectly, but one test still fails.

Specifically the one that states:
" You can POST to /api/users/:_id/exercises with form data description , duration , and optionally date . If no date is supplied, the current date will be used. The response returned will be the user object with the exercise fields added."

The response object I built returns all attributes in the requested format at the specified endpoint.

Keep in mind that I’m providing the url shown below for the tests and all other pass, just not this one.

A quick look at the data inserted by the unit tests shows most records with the date set to “Mon Jan 01 1990”.
I thought it could be the format within the input, but it maps correctly, i.e., my app recognizes “2000-01-30” as “Mon Jan 30 2000”, for instance.
What am I missing? Could there be an issue with timezones here? Or could the tests be at fault?
Logically, if no date is provided, it inserts the present day (also testable via the url below).

As a suggestion, if any admins end up seeing this: I think the test results should specify what was being tested that failed. I understand that if you show the data used in a test people can hard code outcomes, but knowing the name of the test or something would help a lot.

Edit: Removed a link that wasn’t useful

Git Repository:

Your project link(s)
solution: Exercise Tracker

Challenge: Exercise Tracker

It’s hard to tell what the problem is without seeing any code, but one thing I noticed is it’s showing “Ago” instead of “Aug” for August

Good shout. I issued a fix, although that was not the problem.
I made the repos public and added it to the post. Here it is as well

Welcome there,

I am not sure what you are doing in the code (i did not look), but the date is incorrect:
My headers

Your app response

Hope this helps

1 Like

Wow, what a silly mistake, I mapped weekday = 0 to Monday instead of Sunday. Thanks for pointing that out!
That being said, the test still fails after fixing.

Sure. This next one is not entirely your fault:
Here is the request data

Here is the response:

Essentially, the day should be 2 digits. FYI: It is easiest handled with:

const myDate = new Date(req.body.date).toDateString()

Hope this is all that needs changed :slightly_smiling_face:

1 Like

YES! That was the last issue. Thank you very much.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.