I'm trying to run some database queries in a Mocha test but I'm running into 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
The command for running the tests:
mocha --compilers coffee:iced-coffee-script --require iced-coffee-script --require mocha --colors --recursive test"
The error happens on the first line:
ReferenceError: err is not defined
I can only assume that it is attempting to use normal CoffeeScript to execute this code, so it thinks that defer
is a function and attempts to evaluate err
.
Is it possible to write the Mocha tests in IcedCoffeeScript?