Exercise Tracker Test not passing even if the responses are the expected

Hi,
I’m stuck at the 4th project, the Exercise Tracker, for the [Back End Development and APIs Projects] certification.

I send this code to review:

The problem is the test for parsing the date using the toDateString always fails with the following text:

// running tests The

date

property of any object in the


log


array that is returned from

GET /api/users/:id/logs

should be a string.. Use the

dateString

format of the

Date

API. // tests completed

The response my service is sending back are following the structure bellow as you can see in the logs I’m sending into the console.

{
  "_id": "614a639352e6fafb9f3b5876",
  "username": "fcc_test_16322651077",
  "count": 1,
  "log": [
    {
      "description": "test",
      "duration": 60,
      "date": "Mon Jan 01 1990"
    }
  ]
}

Full log for the /api/users/:_id/logs endpoint case


>>>  GET /
 QUERY: {}
 PRAMS: { _id: '614a65dd1d5e2fff6065631b' }
  BODY: {}
 ----------------------------
 RESLT: {
  "_id": "614a65dd1d5e2fff6065631b",
  "username": "fcc_test_16322656939",
  "count": 1,
  "log": [
    {
      "description": "test",
      "duration": 60,
      "date": "Tue Sep 21 2021"
    }
  ]
}
>>>  GET /
 QUERY: {}
 PRAMS: { _id: '614a65df1d5e2fff60656324' }
  BODY: {}
 ----------------------------
 RESLT: {
  "_id": "614a65df1d5e2fff60656324",
  "username": "fcc_test_16322656951",
  "count": 1,
  "log": [
    {
      "description": "test",
      "duration": 60,
      "date": "Tue Sep 21 2021"
    }
  ]
}
>>>  GET /
 QUERY: {}
 PRAMS: { _id: '614a65e01d5e2fff6065632d' }
  BODY: {}
 ----------------------------
 RESLT: {
  "_id": "614a65e01d5e2fff6065632d",
  "username": "fcc_test_16322656964",
  "count": 1,
  "log": [
    {
      "description": "test",
      "duration": 60,
      "date": "Tue Sep 21 2021"
    }
  ]
}
>>>  GET /
 QUERY: {}
 PRAMS: { _id: '614a65e11d5e2fff60656336' }
  BODY: {}
 ----------------------------
 RESLT: {
  "_id": "614a65e11d5e2fff60656336",
  "username": "fcc_test_16322656975",
  "count": 1,
  "log": [
    {
      "description": "test",
      "duration": 60,
      "date": "Tue Sep 21 2021"
    }
  ]
}
>>>  GET /
 QUERY: {}
 PRAMS: { _id: '614a65e21d5e2fff6065633f' }
  BODY: {}
 ----------------------------
 RESLT: {
  "_id": "614a65e21d5e2fff6065633f",
  "username": "fcc_test_16322656987",
  "count": 1,
  "log": [
    {
      "description": "test",
      "duration": 60,
      "date": "Tue Sep 21 2021"
    }
  ]
}
>>>  GET /
 QUERY: {}
 PRAMS: { _id: '614a65e31d5e2fff60656348' }
  BODY: {}
 ----------------------------
 RESLT: {
  "_id": "614a65e31d5e2fff60656348",
  "username": "fcc_test_16322656998",
  "count": 1,
  "log": [
    {
      "description": "test",
      "duration": 60,
      "date": "Tue Sep 21 2021"
    }
  ]
}
>>>  GET /
 QUERY: {}
 PRAMS: { _id: '614a65e41d5e2fff60656351' }
  BODY: {}
 ----------------------------
 RESLT: {
  "_id": "614a65e41d5e2fff60656351",
  "username": "fcc_test_16322657009",
  "count": 1,
  "log": [
    {
      "description": "test",
      "duration": 60,
      "date": "Tue Sep 21 2021"
    }
  ]
}
>>>  GET /?from=1989-12-31&to=1990-01-03
 QUERY: { from: '1989-12-31', to: '1990-01-03' }
 PRAMS: { _id: '614a65e61d5e2fff6065635a' }
  BODY: {}
 ----------------------------
 RESLT: {
  "_id": "614a65e61d5e2fff6065635a",
  "username": "fcc_test_16322657021",
  "from": "Sun Dec 31 1989",
  "to": "Wed Jan 03 1990",
  "count": 2,
  "log": [
    {
      "description": "test",
      "duration": 60,
      "date": "Mon Jan 01 1990"
    },
    {
      "description": "test",
      "duration": 60,
      "date": "Tue Jan 02 1990"
    }
  ]
}
>>>  GET /?limit=1
 QUERY: { limit: '1' }
 PRAMS: { _id: '614a65e61d5e2fff6065635a' }
  BODY: {}
 ----------------------------
 RESLT: {
  "_id": "614a65e61d5e2fff6065635a",
  "username": "fcc_test_16322657021",
  "count": 1,
  "log": [
    {
      "description": "test",
      "duration": 60,
      "date": "Mon Jan 01 1990"
    }
  ]
}

As you could see the date property inside to each object of the log array is of type string.

Is it possible there is a bug on the test ?

Thank you in advice and let me know if I could provide any further usefull information.
Cheers,

Your browser information:

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

Challenge: Exercise Tracker

Link to the challenge:

Welcome there,

When I run your code, it passes all the tests.

Have you resolved the issue?

Hi, @Sky020!

I’m having the same issue as @VictorGreco. All the other test are passing except the one indicated above. The date property of the objects in my log array are all strings.

Below is the link to my code : https://replit.com/@Chucks/boilerplate-project-exercisetracker#.replit

KIndly help out!
Thanks!

Hi @Sky020 ,

I tried again to submit the tests after I shutdown my laptop for the night and the tests passed :man_shrugging:

Could it be there is a cache issue on the tests ?
I didn’t changed a line from yesterday to today.

Thanks !

1 Like

Hi @okechukwu

Try to remove the cache of your browser, it looks this works for my case. :slight_smile:

Remember, the tests are run from your browser. So, if there was a cache issue, only you would be able to tell/resolve it.

Glad you completed the project. Keep it up!

1 Like

Hi @VictorGreco , I didn’t check for the case when the date in req.body is undefined, that’s why it was failing the test. Thanks

1 Like

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