Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverage reporter is asking for lcov.info file if coverage is absent in karma.conf.js reporters #37

Open
sprilukin opened this issue May 15, 2018 · 3 comments

Comments

@sprilukin
Copy link

I'm using Intellij Idea + karma plugin to run karma tests.
Namely, I want to run test coverage.

The issue is that when I run a test with coverage Idea asking me for lcov.info:

screen shot 2018-05-15 at 12 19 02

my karma.conf.js is the following:

module.exports = function(config) {
    return {
        // base path, that will be used to resolve files and exclude
        //        basePath: '',


        // frameworks to use
        frameworks: ['jasmine', 'requirejs'],


        // list of files / patterns to load in the browser
        files: [
            //require.config file
            {pattern: 'src/require.config.js'},

            // tests env libraries
            {pattern: 'src/bower_components/jquery/dist/jquery.js'},
            {pattern: 'src/bower_components/jquery-simulate/jquery.simulate.js'},
            {pattern: 'src/bower_components/jasmine-jquery/lib/jasmine-jquery.js'},
            {pattern: 'src/bower_components/sinonjs/sinon.js'},
            {pattern: 'src/bower_components/sinon-ie/sinon-ie.js'},
            {pattern: 'src/bower_components/jasmine-sinon/lib/jasmine-sinon.js'},

            //source files
            {pattern: 'src/**/*.js', included: false},
            {pattern: 'src/**/*.htm', included: false},
            {pattern: 'src/**/*.json', included: false},


            //all related tests files
            {pattern: 'test/tools/testEnvironment.css'},
            {pattern: 'test/tools/custom.matchers.js'},
            {pattern: 'test/tools/jasmine.ext.js'},
            {pattern: 'test/tools/jquery.cookies.js'},
            {pattern: 'test/mock/**/*.js', included: false},

            //tests loader
            'test/test/test-main.js'
        ],


        // list of files to exclude
        exclude: [

        ],


        // test results reporter to use
        // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
        reporters: ['spec', 'junit'],

        preprocessors: {
            // source files, that you wanna generate coverage for
            // do not include tests or libraries
            // (these files will be instrumented by Istanbul)
            'src/!(bower_components)/**/*.js': ['coverage']

        },

        junitReporter: {
            outputFile: 'test/karma-reports/test-results.xml'
        },

        coverageReporter: {
            includeAllSources: true,
            reporters: [
                {
                    type : 'html',
                    dir : 'test/karma-coverage/coverage/html'
                },
                {
                    type : 'cobertura',
                    dir:   'test/karma-coverage/coverage'
                }
            ]
        },

        // 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_ERROR,


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


        // Start these browsers, currently available:
        // - Chrome
        // - ChromeCanary
        // - Firefox
        // - Opera (has to be installed with `npm install karma-opera-launcher`)
        // - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
        // - PhantomJS
        // - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
        browsers: ["PhantomJS"],

        // If browser does not capture in given timeout [ms], kill it
        captureTimeout: 60000,
        browserNoActivityTimeout: 1000000,


        // Continuous Integration mode
        // if true, it capture browsers, run tests and exit
        //singleRun: true,

        plugins: [
            "karma-jasmine",
            "karma-phantomjs-launcher",
            "karma-chrome-launcher",
            "karma-coverage",
            "karma-junit-reporter",
            "karma-spec-reporter",
            "karma-jasmine-html-reporter",
            "karma-requirejs"
        ]
    };
};

if I'm adding coverage reporter manually it becomes working ok:

        reporters: ['spec', 'junit', 'coverage'],

        coverageReporter: {
            includeAllSources: true,
            reporters: [
                {
                    type : 'html',
                    dir : 'test/karma-coverage/coverage/html'
                },
                {
                    type : 'cobertura',
                    dir:   'test/karma-coverage/coverage'
                },
                {
                    type: 'lcov',
                    dir:   'test/karma-coverage/coverage/lcov'
                }
            ]
        }

however i do not want to have 'coverage' in my reporters by default - it slows down tests.

The solution is to add coverage reporter in intellijCoverageReporter.js, see my pull request

@chorsnell
Copy link

chorsnell commented Sep 27, 2018

Using karma-coverage-istanbul-reporter instead of just karma-coverage I'm not sure the PR works

@segrey
Copy link
Contributor

segrey commented Sep 27, 2018

Let's continue discussion in the https://youtrack.jetbrains.com/issue/WEB-32836.

@dimaqw
Copy link

dimaqw commented Mar 20, 2019

Using karma-coverage-istanbul-reporter instead of just karma-coverage I'm not sure the PR works

How to properly config karma with karma-coverage-istanbul-reporter?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants