用伊斯坦布尔装载mongoose模型

我想为我们的项目实现代码覆盖,所以我们使用grunt-istanbul。 我坚持这个教程: https : //github.com/taichi/grunt-istanbul

我的问题是,当运行针对工具化源代码的testing时,我得到这个错误,但它运行正常代码的testing时正常工作。

>> Mocha exploded! >> MongooseError: Schema hasn't been registered for model "Comm". >> Use mongoose.model(name, schema) >> at Mongoose.model (/Users/user/repos/review.ninja/node_modules/mongoose/lib/index.js:322:13) >> at Object.<anonymous> (/Users/user/repos/review.ninja/test/coverage/instrument/src/server/api/comm.js:9:147) >> at Module._compile (module.js:449:26) >> at Object.Module._extensions..js (module.js:467:10) >> at Module.load (module.js:349:32) >> at Function.Module._load (module.js:305:12) >> at Module.require (module.js:357:17) >> at require (module.js:373:17) >> at /Users/user/repos/review.ninja/node_modules/grunt-mocha-test/node_modules/mocha/lib/mocha.js:172:27 >> at Array.forEach (native) >> at Mocha.loadFiles (/Users/user/repos/review.ninja/node_modules/grunt-mocha-test/node_modules/mocha/lib/mocha.js:169:14) 

我们还出口mongoose.model('Comm', CommSchema); 在通信模块中,并将其导入到testing代码中。 如前所述,如果正常运行Mochatesting,它将起作用。