Open realph opened 9 years ago
instead of expect(controller.customers).to.have.length(5);
try expect(controller.customers.length).to.equal(5);
then if you get the 'cannot get length of undefined' error, you'll know the issue is with controller.customers
Hiya folks, I'm trying to create a unit test that checks if a GET request returns the correct amount of items, but I'm using mock data to do this.
My test looks like this:
test.js
I keep getting this error when I run the test:
It looks like
controller.customers
is coming back asundefined
for some reason. Am I mocking the data correctly?My controller looks like this:
I've put a
console.log
in the test, and mycustomers
variable is returning 5 objects which appear to be empty. Perhaps this is the issue?I'm very new to this and can't work out what I'm doing wrong. I don't even know how to debug such an issue.
Any help is appreciated. Thanks in advance!