Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mocha: Cannot read property 'be' of undefined

I'm writing unit test for my project. But I always meet this problem

Cannot read property 'be' of undefined.

I have a test suite called model-xxx, and I wanna try each method in this model. So each method I write a sub test suite in model-xxx. like this:

enter image description here

And each method is related with mongoose, so I hope these sub suite will be async. so each method I write done() in before and after and it

but none of these suite passed. error like this:

enter image description here

and like this:

Cannot read property 'not' of undefined.

why this occurs? does this mean something wrong with my should.js? but it doesn't make sense

hope for solutions.

like image 282
李浩然 Avatar asked Dec 02 '22 15:12

李浩然


1 Answers

Chai's should is a function that needs to be called before you can use should-style assertions:

var should = require('chai').should();

See the documentation.

like image 154
robertklep Avatar answered Dec 17 '22 02:12

robertklep