Tell us what’s happening:
I’m trying to finish my issue tracker app, but I’ve run into an issue where the only tests that pass are the post requests. I know that they are all not done yet, but I can’t tell whats wrong with my delete requests or my get requests, as the get request should be passing with no parameters easily.
Your code so far My repl all routes are in the api.js file.
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36.
Ok, I’ve gotten a bit more of a handle on things now, that was very helpful!. I’m certainly not done, and realized that I should probably have the mocha tests written, as they’ll help me debug even easier.
I wrote the first one, but it does not work at all. I’m getting the following error:
Tests are not valid:
/home/runner/boilerplate-project-issuetracker/tests/2_functional-tests.js:11
test('create with every field', function(done){
^^^^
SyntaxError: Invalid destructuring assignment target
at wrapSafe (internal/modules/cjs/loader.js:1053:16)
at Module._compile (internal/modules/cjs/loader.js:1101:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at /home/runner/boilerplate-project-issuetracker/node_modules/mocha/lib/mocha.js:394:36
at Array.forEach (<anonymous>)
at Mocha.loadFiles (/home/runner/boilerplate-project-issuetracker/node_modules/mocha/lib/mocha.js:391:14)
at Mocha.run (/home/runner/boilerplate-project-issuetracker/node_modules/mocha/lib/mocha.js:970:10)
at EventEmitter.emitter.run (/home/runner/boilerplate-project-issuetracker/test-runner.js:58:32)
at Timeout._onTimeout (/home/runner/boilerplate-project-issuetracker/server.js:56:16)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7)
Hi again, If you could possibly help me out again, I’m getting this error in the dev console when I run the free code camp tests on the app .
Error: expected { Object (result, _id) } to deeply equal { Object (error, _id) }
at eval (eval at <anonymous> (VM66 frame-runner.48f6f4fc3b0f26107e07.js:32), <anonymous>:23:11)
but I’m outputting everything and it is returning the right format object when its supposed to. I really can’t seem to figure out whats going wrong. This appears to be an issue with my put requests.
On a quick glance, I would say just to be sure you are breaking out of any execution, once you respond. That is, use return res.json(...); where applicable.
Ok so everything works properly for the user, like you can do all the CRUD operations, and I’ve written the tests out, which work properly. I’m still getting the error I mentioned above, as if they’re looking for the wrong output when I run the tests.
I’m a little confused as to which block of code is which. The last one is whats expected, the third one is the response from my app? What is the second block?
Also thank you a ton for your patience and help with this project. Its extremely useful!
So this is the Id its sending, and it wants it to be treated as an invalid id, the problem is that it appears to be valid!? The only other issue I can think of is that its sending an id for something that it cannot update, but I think that would return an error from mongoose, as it couldn’t find a document.
and in writing this i found the solution. Mongoose returns null, not an error, if the document wasn’t found. so now my findbyidandupdate looks like this