Tell us what’s happening:
I passed all the tests except the 10 tests.
All of them pass in my backend, but still cannot pass the exam.
What is the tester looking for? How do I solve this?
Also I noticed the first test always fail. Any way I can tell the tester script to wait until mongoose is connected?
I pasted your test code into my repl (as I’ve previously completed this project) and you are failing 2 of the functional tests:
1) Functional Tests Routing tests GET /api/books/[id] => book object with [id] Test GET /api/books/[id] with valid id in db:
Uncaught AssertionError: Books in array should contain commentcount: expected { Object (_id, title, ...) } to have property 'commentcount'
at tests/2_functional-tests.js:112:20
at Test.Request.callback (node_modules/superagent/lib/node/index.js:716:12)
at node_modules/superagent/lib/node/index.js:916:18
at IncomingMessage.<anonymous> (node_modules/superagent/lib/node/parsers/json.js:19:7)
at IncomingMessage.emit (node:events:402:35)
at endReadableNT (node:internal/streams/readable:1343:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
2) Functional Tests Routing tests POST /api/books/[id] => add comment/expect book object with id Test POST /api/books/[id] with comment:
Uncaught AssertionError: Books in array should contain commentcount: expected { Object (_id, title, ...) } to have property 'commentcount'
at tests/2_functional-tests.js:134:20
at Test.Request.callback (node_modules/superagent/lib/node/index.js:716:12)
at node_modules/superagent/lib/node/index.js:916:18
at IncomingMessage.<anonymous> (node_modules/superagent/lib/node/parsers/json.js:19:7)
at IncomingMessage.emit (node:events:402:35)
at endReadableNT (node:internal/streams/readable:1343:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21)