I think there’s something I’m missing about how Mocha works… please help!
I don’t have time to get this up and running right now…
First of all, when asking questions, please provide better information. What was the exact error message? Any indication of what test? What line? What variable? And just because something works doesn’t mean that all the tests magically pass. There may be things they are testing that you are not and they may be more precise than you are being.
Anyway, I’m no mocha/chai guy (mostly using jest atm) but the error fragment that you provided seems to indicate that the assert.equal
has an undefined
as the first parameter and a blank
as the second. I say blank
because you didn’t provide the full error message.
My first instinct would be to put console.log statements in all of those callbacks, right before the assert
s and find out exactly what you are getting for res.
solved!
For some reason res.body only gets defined when you use res.json in your api (I was using res.send)
All good now!
Well… almost. Why? Why is this the case?
I don’t know, I’d have to see the code.