Quality Assurance Projects - Personal Library

Tell us what’s happening:

my code of “api.js” has pass the test, but there are two failing in “2_funcitonal-tests.js” , one is below, the other failing of “id not in db” functional tests is similar problem .

  1. Functional Tests Routing tests GET /api/books/[id] => book object with [id] Test GET /api/books/[id] with id not in db:
    Uncaught CastError: Cast to ObjectId failed for value “test id” (type string) at path “_id” for model “Book”
    Your project link(s)

The bigger problem is the browser will crash when type a id not in db, I don’t know if it’s a bug in my “2_funcitonal-tests.js” or in somewhere else? could someone help ?

solution: boilerplate-project-library - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36

Challenge: Quality Assurance Projects - Personal Library

Link to the challenge:

I assume it is trying to convert 'test id' to a valid id. Try creating a “fake” valid id that doesn’t exist in the DB but is in a valid format.

507f1f77bcf86cd799439011

Thanks for your help, the failing message is interesting, it’s works.

  1. Functional Tests Routing tests GET /api/books/[id] => book object with [id] Test GET /api/books/[id] with id not in db:
    Uncaught AssertionError: expected {} to equal ‘no book exists’

Look at your other tests. You are not using res.body but…something else. That is what you should do in that test as well.

And you still need to fix the id for the DELETE test.

Yeah, after changed all the res.body to res. text, all my tests passed, this the problem crashing the browser and DB, but I am still confused how to use them correctly. many thanks for fix my problem!

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