I am trying to run some database queries in a Mocha test, but I am having some problems.
Here's the test (using Mongoose):
it.only "should create some objects", (done) -> await models.MyModel1.count defer(err, oldModel1Count) await models.MyModel2.count defer(err, oldModel2Count) # ... do some stuff await models.MyModel1.count defer(err, newModel1Count) await models.MyModel2.count defer(err, newModel2Count) assert.equal oldModel1Count + 1, newModel1Count assert.equal oldModel2Count + 1, newModel2Count
Command to run tests:
mocha --compilers coffee:iced-coffee-script --require iced-coffee-script --require mocha --colors --recursive test"
The error in the first line:
ReferenceError: err is not defined
I can only assume that he is trying to use regular CoffeeScript to execute this code, so he thinks defer is a function and trying to evaluate err .
Can I write Mocha tests in IcedCoffeeScript?
source share