In Exercise Tracker, can't figure out why test won't pass

Tell us what’s happening:
My project on glitch found here. And the glitch codepage is here

I thought I had finshed the project but the fourth test doesn’t pass. The test states:

I can add an exercise to any user by posting form data userId(_id), description, duration, and optionally date to /api/exercise/add. If no date supplied it will use current date. App will return the user object with the exercise fields added.

It seems to be functioning correctly. Using the form located at ‘/’, an exercise is successfully added to the user in Mongo. Here is an example return from the post to ‘/api/exercise/add’ posted from the form at ‘/’

{"_id":“5f1f76ef6949d714ecbb98b3”,“username”:“John”,“date”:“7/27/2020”,“duration”:50,“description”:“Litnin fast scales on me gitar”}

And here is a sample from the same call at the model project:

{"_id":“5f1b3688e5835d007e76e5a3”,“username”:“fred the second”,“date”:“Tue Jul 28 2020”,“duration”:49,“description”:“Rock crunching”}

What am I missing?

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36.

Challenge: Exercise Tracker

Link to the challenge:

Hey there,

when I added an exercise, I got this back:

{
  "_id":"5f1fd35c7ce3f400b01b85c9",
  "username":"test01",
  "date":"7/28/2020",
  "duration":1,
  "description":"testdes"
}

The test says:
I can add an exercise [...] . App will return the user object with the exercise fields added.

Thanks for looking into this.
I am still perplexed. It looks right to me. The _id field is the user id (I checked the database to be sure) . The _id and username are from the user object. The date, duration and description are from the exercise fields.

I just had a look into the tests on Github, you can find it here.

Try to debug it on your own and let me know if you need additional help.

Thanks, That led me to the answer. The test looks for a specific date format in the json response. I fixed that up and it passed

 const expected = {
        username,
        description: 'test',
        duration: 60,
        _id,
        date: 'Mon Jan 01 1990'
    };
1 Like

Great work! :+1: :+1: