La cobertura del código Karma / Istanbul no encuentra funciones y siempre devuelve el 100%

Estoy intentando agregar cobertura de código para mis pruebas de Karma, sin embargo, aunque encuentra el archivo JS correcto que estoy probando, no encuentra las funciones dentro de esos archivos.

Por lo que he leído hasta ahora, creo que tiene que ver con que los archivos no se naveguen correctamente antes de pasar a Estambul para hacer la cobertura, pero es cierto que soy nuevo en esto, así que espero algunas sugerencias.

Aquí está mi archivo JS (common.js):

var applicationSettings = require('./settings');

var common = {
    getAjaxBaseUrl: function () {
        var strVirtualDirectory = applicationSettings.VirtualDirectory;
        if (strVirtualDirectory.length > 1) {
            if (!strVirtualDirectory.startsWith("/")) {
                strVirtualDirectory = "/" + strVirtualDirectory;
            }
        }
    return strVirtualDirectory;
   }
}
module.exports = common;

Y aquí están las pruebas que he escrito:

it('Client - Should get correct AjaxBaseUrl with /', function () {
    var clientSettings = require('./../client/scripts/settings');
    var clientCommon = require('./../client/scripts/common');

    clientSettings.VirtualDirectory = '/VD';
    expect(clientCommon.getAjaxBaseUrl()).to.equal('/VD');

});

it('Client - Should get correct AjaxBaseUrl without /', function () {
    var clientSettings = require('./../client/scripts/settings');
    var clientCommon = require('./../client/scripts/common');

    clientSettings.VirtualDirectory = 'VD';
    expect(clientCommon.getAjaxBaseUrl()).to.equal('/VD');
});

Mi Karma.conf está abajo:

// Karma configuration
// Generated on Mon Jan 11 2016 09:43:00 GMT+0000 (GMT Standard Time)

module.exports = function (config) {
    config.set({

        // base path that will be used to resolve all patterns (eg. files, exclude)
        basePath: '',

        // frameworks to use
        // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
        frameworks: ['phantomjs-shim', 'browserify', 'mocha'],

        // list of files / patterns to load in the browser
        files: [
            'https://code.jquery.com/jquery-2.2.0.min.js',
            'http://cdn.kendostatic.com/2015.3.1111/js/kendo.all.min.js',
            'test_unit/*Spec.js',
            'client/scripts/*.js'
        ],

        // list of files to exclude
        exclude: [
        ],

        // preprocess matching files before serving them to the browser
        // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
        preprocessors: {
            'test_unit/*Spec.js': ['browserify'],
            'client/scripts/*.js': ['browserify', 'coverage']    
        },

        // test results reporter to use
        // possible values: 'dots', 'progress'
        // available reporters: https://npmjs.org/browse/keyword/karma-reporter
        reporters: ['progress', 'coverage', 'junit'],

        // Configure jUnit reporter
        junitReporter: {
            outputDir: '', // results will be saved as $outputDir/$browserName.xml 
            outputFile: undefined, // if included, results will be saved as $outputDir/$browserName/$outputFile 
            suite: '', // suite will become the package name attribute in xml testsuite element 
            useBrowserName: true // add browser name to report and classes names 
        },

        // Configure coverage reporter
        coverageReporter: {
            type: 'html',
            dir: 'test_coverage',
            subdir: '.',
            file: 'coverage.htm'
        },

        // web server port
        port: 9876,

        // enable / disable colors in the output (reporters and logs)
        colors: true,

        // level of logging
        // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
        logLevel: config.LOG_INFO,

        // enable / disable watching file and executing tests whenever any file changes
        autoWatch: false,

        browserify: {
            configure: function (bundle) {
                bundle.transform('reactify', { extensions: ['.jsx'] });
            }        
        },        

        // Continuous Integration mode
        // if true, Karma captures browsers, runs the tests and exits
        singleRun: true,

        // Concurrency level
        // how many browser should be started simultaneous
        concurrency: Infinity,

    })
}

Esto produce un informe, pero muestra el 100% y la única línea que se encuentra en el archivo common.js es:

require("C:\\Source\\ProjectName\\client\\scripts\\common.js");

Intenté agregar Browerify-Istanbul en la mezcla, agregando un requisito para ello en la parte superior del Karma.conf una transformación adicional en la sección browserify

bundle.transform(istanbul)

Sin embargo, esto solo hace que mis pruebas fallen y arrojen varios errores:

undefined no es un objeto (evaluando '__cov_qQLFhXEMt7fatxiMx0_vQQ.b [' 1 '] [0]') getAjaxBaseUrl @ C: /Users/CHARLE~1.WIC/AppData/Local/Temp/0d61da722d2838c9 600b83d1: 43b0c: /Users/CHARLE~1.WIC/AppData/Local/Temp/0d61da722d2838c9600d83d1cbb4c0b 8.browserify: 51742: 1849

16 02 2016 09: 14: 08.515: ERROR [cobertura]: [TypeError: No se puede leer la propiedad 'star t' de undefined] TypeError: No se puede leer la propiedad 'start' de undefined en C: \ Source \ ProjectName \ node_modules \ istanbul \ lib \ o bject-utils.js: 59: 44 en Array.forEach (nativo) en Object.addDerivedInfoForFile (C: \ Source \ ProjectName \ node_modules \ istanbul \ lib \ object-utils.js: 58: 37) en Object.Collector .fileCoverageFor (C: \ Source \ ProjectName \ node_modules \ istanbul \ lib \ collector.js: 94: 15) en C: \ Source \ ProjectName \ node_modules \ istanbul \ lib \ r eport \ html.js: 558: 90 en Array .forEach (native) en HtmlReport.Report.mix.writeReport (C: \ Source \ ProjectName \ node_modules \ istanbul \ lib \ report \ html.js: 557: 27) en writeReport (C: \ Source \ ProjectName \ node_modules \ k arma-coverage \ lib \ reporter.js: 62: 16) en C: \ Source \ ProjectName \ node_modules \ karma-coverage \ lib \ reporter.js: 288: 11 en C: \ Source \ ProjectName \ node_modules \ karma \ lib \ help er.js: 82: 7 en FSReqWrap.oncomplete (fs.js: 82: 15)

¿Me estoy perdiendo algo o me estoy equivocando?

Respuestas a la pregunta(2)

Su respuesta a la pregunta