I'm trying to use mocha to test my express app. My folder structure is:
myapp
|-app
|--models
|-test
|--mocha-blanket.js
|--mocha
|--karma
|-server.js
server.js
is my express server. I had that before in options.require
, but the documentation said to use a blanket.js
. My mocha-blanket.js
is:
var path = require('path');
var srcDir = path.join(__dirname, '..', 'app');
require('blanket')({
// Only files that match the pattern will be instrumented
pattern: srcDir
});
My Gruntfile has:
mochaTest:
options:
reporter: "spec"
require: 'test/mocha-blanket.js'
# require: "server.js"
coverage:
options:
reporter: 'html-cov',
captureFile: 'mocha-coverage.html'
src: ["test/mocha/**/*.js"]
The error I'm getting is:
>> Mocha exploded!
>> MissingSchemaError: Schema hasn't been registered for model "Company".
>> Use mongoose.model(name, schema)
>> at Mongoose.model (/myapp/node_modules/mongoose/lib/index.js:315:13)
>> at Object.<anonymous> (/myapp/test/mocha/controllers/company.js:4:22)
>> at Module._compile (module.js:456:26)
>> at Module._extensions..js (module.js:474:10)
I'm sure I'm doing something (or a lot of things) incorrectly. But I'm not sure what. Any ideas?