0

When using the coverage reporter with karma and requirejs, I am running into issues with loading one of my modules. More specifically, the module being loaded in is throwing the rather cryptic error message shown below:

screen shot 2014-10-01 at 12 22 50 pm

After some digging around, I isolated the problem to the following statement in the module code that is generated by Karma/Istanbul:

karma_debug_runner

If I remove the App.Controller module from the coverage report, all works as expected. There is nothing extraordinary about the module itself and even returning a blank object as the module will cause the error to be thrown and the tests to fail.

I am currently running karma using the following dependencies:

"karma-safari-launcher": "~> 0.1.1",
"karma-ievms": "~> 0.0.4",
"karma": "~> 0.12.16",
"karma-cli": "~> 0.0.4",
"karma-coverage": "~> 0.2.1",
"karma-requirejs": "~0.2.1",
"phantomjs": "~1.9.7-5",
"karma-phantomjs-launcher": "~0.1.4",
"karma-chrome-launcher": "~0.1.3",
"karma-firefox-launcher": "~0.1.3",
"karma-jasmine": "~> 0.1.0",
"karma-osx-reporter": "~> 0.1.0"

and my karma.conf looks like this:

(function () {
    'use strict';

    module.exports = function (config) {
        config.set({
            basePath: '',
            frameworks: ['jasmine', 'requirejs'],
            reporters: ['progress', 'coverage'],
            browsers: ['Chrome'],
            autoWatch: true,
            logLevel: config.LOG_INFO,
            colors: true,
            captureTimeout: 60000,
            singleRun: false,
            runnerPort: 9100,
            port: 9456,
            hostname: 'localhost',

            preprocessors: {
                "src/Apps/Signup/Slim_Account/**/*.js": ['coverage'],
                "src/Apps/Signup/Slim_Account/*.js": ['coverage']
            },

            coverageReporter: {
                type: 'lcov',
                dir: 'coverage/'
            },

            files: [
                // Deps
                {
                    pattern: 'libs/**/*.js',
                    included: false
                }, {
                    pattern: 'bootstrap/**/*.js',
                    included: false
                }, {
                    pattern: 'src/**/*.svg',
                    included: false
                }, {
                    pattern: 'src/**/*.html',
                    included: false
                }, {
                    pattern: 'test/**/*.html',
                    included: false
                }, {
                    pattern: 'src/**/*.json',
                    included: false
                }, {
                    pattern: 'test/**/*.json',
                    included: false
                },

                'test/libs/velesin-jasmine-jquery/lib/jasmine-jquery.js',
                'test/helpers/lv-helpers.js',
                'test/helpers/lv-matchers.js',

                // src
                {
                    pattern: 'src/**/*.js',
                    included: false
                },

                // Tests
                {
                    pattern: 'test/src/unit/Apps/Signup/Slim_Account/**/*._SPEC.js',
                    included: false
                },

                'test/test-slim-account-signup-main.js'
            ],
            exclude: [
                'src/Apps/Signup/Slim_Account/App.Bootloader.js'
            ]
        });
    };
})();

Been trying to fix this for a couple days now, to no avail. Any help or direction would be greatly appreciated.

wvandaal
  • 4,265
  • 2
  • 16
  • 27
  • A very wild guess: the files from the 1st line in your preprocessors is a superset of the files in the second line; could it be that `"src/Apps/Signup/Slim_Account/*.js"` are getting instrumented twice? Could you try *removing* the seconf line from your preprocessors? – Nikos Paraskevopoulos Oct 04 '14 at 21:31
  • possible duplicate of [Karma and CoffeScript and Code Coverage](http://stackoverflow.com/questions/26471962/karma-and-coffescript-and-code-coverage) – Paul Sweatte Jul 16 '15 at 20:23

0 Answers0