Istanbul closure report incorrect for mocha test (using Mongoose)

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) {
    // !!! Marke as not covered
    log.trace('BaseSchema CTOR : objectName=%s schema=%s', objectName, schema);
    Schema.apply(this, [schema]);
...
    this.statics.removeAll = function (cb) {
        // !!! marked as not covered
        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 packages/**/mocha/**/*.js

Any hints would be greatly appreciated.

Jm.

+4
source share
1 answer

, , , .

package.json

"test": "./node_modules/istanbul/lib/cli.js cover ./node_modules/.bin/_mocha ./test/*.js --  --recursive -R spec -r should"

http://localhost:<PORT>/coverage

, .

0

Source: https://habr.com/ru/post/1542279/


All Articles