Ok, so I added test back in and now I’m getting a new error. The test again are all showing as passed but then I’m getting this error. How can I be passing the tests but getting this error that’s in one of the tests?
My solution link is updated.
I had a look at your code and there are issues with earlier tests. I’ll have a play around with it when I get home and let you know if I figure out why your res.body[0] is coming up undefined.
Thanks. I can’t for the life of me work out why it’s returning undefined.
I also don’t understand why the tests are showing as passed even though they clearly aren’t…
A lot of the tests really should POST data before testing it. You shouldn’t rely on hardcoded values, they should be the actual values you get back from using the API.
Apologies, I didn’t get a chance for a proper look at your code until now.
The good news is that I forked your repl and played around with it and now it works.
The bad news is that I’m not entirely sure what was causing it to fail previously, though there were a number of issues which I fixed (all in the functional-tests file).
I’m working right now but I’ll come back to you again later with my findings…
Thanks dude. I’ve had another go at this now that I’ve taken a break and I think I worked out my issues.
I think all the tests are passing now with no errors. But when I click ‘I completed this challenge’ all the tests seem to time out with freeCodeCamp. Any ideas how I get this to pass?
There is a problem with the tests hanging the repl (which then causes the FCC tests to timeout). I think that some of the boilerplates have recently been updated to prevent this but - if you experience this issue again - another simple fix is to add this to the bottom of your functional-tests file:
This restarts the repl, preventing the timeouts caused by a hanging repl.
The only other observation I have is that you use assert.equal for all of your tests.
It’s no criticism but, if I want to assert that something is an object for instance, I’d personally use assert.isObject(res.body[0], 'res.body[0] is an object'). There’s a whole library of useful assertions which can make the code a little cleaner I think.