Issue Tracker first PUT request test failing despite working correctly

Hello everyone.

Im banging my head against this project for a long time, and I just have no idea why first PUT test isn’t passing.

Everything seems to be working (so far, as I havent done much with DELETE yet).

I’d greatly appreciate any advice, thank you in advance.

The test does a GET after the PUT and the expected response is an array with the single issue that was updated. You seem to be sending an array with the project.

Request URL: https://boilerplate-project-issuetracker.verminatorx.repl.co/api/issues/fcc-project?_id=655d000b6a4764047e528f3d`

Your GET response:


[
    {
        "_id": "64e66eb30eaee215c03b05e6",
        "name": "fcc-project",
        "issues": {
            "issue_title": "Issue to be Updated",
            "issue_text": "New Issue Text",
            "created_by": "fCC",
            "assigned_to": "",
            "status_text": "",
            "created_on": "Tue Nov 21 2023 19:07:55 GMT+0000 (Coordinated Universal Time)",
            "updated_on": "Tue Nov 21 2023 19:07:55 GMT+0000 (Coordinated Universal Time)",
            "open": true,
            "_id": "655d000b6a4764047e528f3d"
        },
        "__v": 404
    }
]

That causes this error as seen in the browser console.

Error: expected NaN to be above NaN

Caused by this test code:

const getUpdatedId = await $.get(url + '?_id=' + itemToUpdate._id);
assert.isArray(getUpdatedId);
assert.isObject(getUpdatedId[0]);
assert.isAbove(
  Date.parse(getUpdatedId[0].updated_on),
  Date.parse(getUpdatedId[0].created_on)
);

Also, it doesn’t look like you updated the updated_on field as it is the same as the created_on.

The tests:

https://github.com/freeCodeCamp/freeCodeCamp/blob/main/curriculum/challenges/english/06-quality-assurance/quality-assurance-projects/issue-tracker.md

1 Like

Thank you so much. This helped me.
I had the situation that (valid) PUT test was failing, as was the (valid) DELETE test.
Taking a look at the test, I noticed that within the PUT test, a POST request happens before. So when I wrote according test and did some console.logging, I found out that the MongoDB ObjectId()s were causing the problem that I did not actually find the issue that had to be updated or deleted. using .toString() was the solution then.