Quality Assurance Projects - Issue Tracker

Hello, I’m hoping someone might be able to help with my Issue Tracker code please. I think I’m almost there but struggling to pass tests 9 and 10. I’ve tried copying the fcc tests from the github repository into my functional tests, which are all passing in my console. I’m guessing somewhere in my api route codes for “put” and “delete” something is going wrong, and is appearing to be successful when it should return an error, but I’m not sure. Any feedback or suggestions would be much appreciated.

Tests 9 and 10 are:

  • When the PUT request sent to /api/issues/{projectname} does not include update fields, the return value is { error: 'no update field(s) sent', '_id': _id }. On any other error, the return value is { error: 'could not update', '_id': _id }.

  • You can send a DELETE request to /api/issues/{projectname} with an _id to delete an issue. If no _id is sent, the return value is { error: 'missing _id' }. On success, the return value is { result: 'successfully deleted', '_id': _id }. On failure, the return value is { error: 'could not delete', '_id': _id }.

The messages I’m seeing on freecodecamp for tests 9 and 10 are:

[Error: expected { Object (result, _id) } to deeply equal { error: ‘could not update’, …(1) }]
[Error: expected { Object (result, _id) } to deeply equal { error: ‘could not delete’, …(1) }]

The link to my Replit: boilerplate-project-issuetracker - Replit

Link to my solution: https://8f12e8e0-9f4f-47d9-b6e0-aa55dd7a206b-00-gerr79xltsr1.janeway.replit.dev/

Your browser information:

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

This is the challenge:
Quality Assurance Projects - Issue Tracker

Hi, thank you to everyone who’s viewed this so far. I think I’ve found the issue, but still unsure how to resolve it. In the browser on my solution page, when I enter an ID that doesn’t exist in the database, but is in the correct mongoose ObjectId format, the “put” and “delete” requests are successful, where they should fail. Entering a completely wrong Id that isn’t formatted at all fails as expected. Does anyone know why findOneAndDelete or findOneAndUpdate would accept an Id that is not in the database? I’ve also tried findByIdAndDelete but getting the same result.

Hi, just wanted to give an update in case anyone else finds themselves stuck too. I finally passed. In the “put” and “delete” middleware, I already had the functions findOneAndUpdate, and findOneAndDelete. However, they were finding documents that didn’t exist. I had to add an extra step of “findById” then ALSO console log the results of that, to make it fail eg. console.log(foundDocument). Then it fails as it should. I’ve added a screenshot below of part of my delete middleware to hopefully give an idea of what I mean. I wrote similar code in the “put” middleware. If this makes no sense let me know and I can try to explain it better. If anyone knows why I had to do this, please let me know!


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