I tried Istanbul to get a trial test for my application. Everything seems to work fine, but some methods are marked as not covered, and I am sure (beacause of logs) that these functions are covered. Here is the code I want to test (using Mongoose):
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
function BaseSchema(objectName, schema) {
log.trace('BaseSchema CTOR : objectName=%s schema=%s', objectName, schema);
Schema.apply(this, [schema]);
...
this.statics.removeAll = function (cb) {
log.debug('Calling %s.removeAll', this._objectName);
this.remove({}, cb);
};
...
util.inherits(BaseSchema, Schema);
and my test class:
describe('Advanced CRUD Account :', function () {
it('Should remove all', function (done) {
account = new Account({
email: 'testu@test.com',
pseudo: 'Testu'
});
Account.removeAll(function () {
done();
});
});
I see the logs, so I'm sure the method is well called.
I run a coverage check with this command:
istanbul cover node_modules/mocha/bin/_mocha -- -r server.js -R spec test/mocha*.js packagesmocha*.js
Any hints would be greatly appreciated.
Jm.
source
share